Friday, 2 October 2015

Chapter 17: Counting Frequencies


17.3 Using the data set Blood, produce frequencies for the variable Chol (cholesterol). Use a format to group the frequencies into three groups: low to 200 (normal), 201 and higher (high), and missing. Run PROC FREQ twice, once using the MISSING option, and once without. Compare the percentages in both listings.

Ans.


Output:  




Explanation:

  1.  PROC FREQ can use either raw data or cell count data to produce frequency and crosstabulation tables.
  2. The TABLES statement requests one-way to n-way frequency and crosstabulation tables and statistics for those tables
  3. Cell count data report the data as a table, listing all possible combinations of data values along with the frequency counts.
  4.  Nocum is an option which suppresses the information.


Learning: 

If you omit the TABLES statement, PROC FREQ generates one-way frequency tables for all data set variables that are not listed in the other statements.


17.5 Using the SAS data set College, create a two-way table of Scholarship (rows) by ClassRank (columns). Use a user-defined format to group class rank into two groups: 70 and lower, and 71 and higher.

Ans.   



Output:

Explanation:

  1. proc format is used to make a format for the table.
  2. Since its a two way table, in table statement we are only mentioning Scholarship and ClassRank.

Learning:
Proc format is used to transform the numeric variables to categorical variables.



17.7 Using the SAS data set Blood, produce a table of frequencies for BloodType, in
frequency order.

Ans. 


Output: 


Explanation:


  1. In this problem the tables specifies frequency. 
  2. And nocum has to be mentioned because we want only frequency.


Learning: 

If in this we will not mention nocum nopercent, then a new column will be created which will show the percentage of each blood groups.

Conclusion: 

FREQ can be used to directly generate output or to create SAS datasets for further processing. While the output can be obtained from these procedure is very readable.


Chapter 18: Creating Tabular Reports

18.1 Produce the following table. Note that the last row in the table represents all subjects.
Demographics from COLLEGE Data Set. 


 Ans: 



 Output:



Explanation:

  1. The tabulate procedure displays the descriptive statistics in tabular format.
  2. The simplest possible table in TABULATE has to have three things: a PROC TABULATE statement, and a CLASS or VAR statement.
  3. PROC TABULATE computes many of the same statistics that are computed by other descriptive statistical procedures such as MEANS, FREQ, and REPORT. 


Learning: PROC TABULATE provides  
  1. simple but powerful methods to create tabular reports   
  2. flexibility in classifying the values of variables and establishing hierarchical relationships between the variables 
  3. mechanisms for labeling and formatting variables and procedure-generated statistics.


18.3  Produce the following table. Note that the ALL column has been renamed Total and
Gender has been formatted.


Ans:








 Output: 


Explanation:

  1. rts option provides enough space to display the column headings
Learning:
The statements that create this report
  1. customize column and row headings
  2. apply a format to all table cells
  3. sum expenditures for residential and business customers
  4. compute subtotals for each division
  5. compute totals for all regions.
Conclusion: 
So after solving these problems, we understood the use of PROC TABULATE and able to produce simple tables.


Chapter 21: Using Advanced INPUT techniques

21.5 You want to read observations from the SAS data set Bicycles. Using a DATA_NULL_ step, sum the value of units sold (Units) and the sum of Sales (TotalSales)for all the observations. Call the former TotalUnits and the latter Sum_of_Sales. Use a SET option to test when the last observation from Bicycles is being read and, using a PUT statement, list the values of the two variables TotalUnits and Sum_of_Sales.

Ans.



Output:


Explanation: 

  1. In this PUT statement is used.
  2. It can be used to write lines that contain variable values, character string etc


Learning:
The PUT statement without arguments is called a NULL  PUT statement.