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:
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:
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:
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:
Learning: PROC TABULATE provides
18.3 Produce the following table. Note that the ALL column has been renamed Total and
Gender has been formatted.
Ans:

Output:
Explanation:
The statements that create this report
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:
Learning:
The PUT statement without arguments is called a NULL PUT statement.
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:
- PROC FREQ can use either raw data or cell count data to produce frequency and crosstabulation tables.
- The TABLES statement requests one-way to n-way frequency and crosstabulation tables and statistics for those tables
- Cell count data report the data as a table, listing all possible combinations of data values along with the frequency counts.
- 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:
- proc format is used to make a format for the table.
- 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:
- In this problem the tables specifies frequency.
- 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:
- The tabulate procedure displays the descriptive statistics in tabular format.
- The simplest possible table in TABULATE has to have three things: a PROC TABULATE statement, and a CLASS or VAR statement.
- PROC TABULATE computes many of the same statistics that are computed by other descriptive statistical procedures such as MEANS, FREQ, and REPORT.
- simple but powerful methods to create tabular reports
- flexibility in classifying the values of variables and establishing hierarchical relationships between the variables
- 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:
- rts option provides enough space to display the column headings
The statements that create this report
- customize column and row headings
- apply a format to all table cells
- sum expenditures for residential and business customers
- compute subtotals for each division
- compute totals for all regions.
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:
- In this PUT statement is used.
- 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.