Showing posts with label Report. Show all posts

Learning SAS: Counting Frequencies - PROC FREQ

As PROC MEANS is very helpful in performing various operations on Numeric variables, PROC FREQ can be used to count frequencies of both character and numeric variables,
in one-way, two-way (Crosstabs/Contingency Tables), and three-way tables.

Problem 1:

Using the SAS data set Blood, generate one-way frequencies for the variables Gender, BloodType, and AgeGroup. Use the appropriate options to omit the cumulative statistics and percentages (17.1)

Input:





Solution:

Title 'Frequency of Gender BloodType Age group without Cum.Freq. and %';
PROC FREQ DATA=A15001.A01_BLOOD; 
 TABLE GENDER BLOODTYPE AGEGROUP /NOCUM NOPERCENT;
RUN; 
Title;

Output:

Learning:

  • How to use PROC FREQ to build a one-way frequency table
  • Different Options of PROC FREQ like NOCUM and NOPERCENT



Friday, October 2, 2015
Posted by Netbloggy

Learning SAS: Summarizing Data (PROC MEANS)

We've seen the basic data manipulation options with SAS in our previous blogpost and it's time for us to understand how to report those processed data. And the first think that comes in this journey is PROC MEANS.

People think of PROC MEANS just as a way to calculate summary statistics of numeric values but these procedures are much more versatile and can be used to create summary data sets that can then be analyzed with more DATA or PROC steps.

Problem 1:

Using the SAS data set College, compute the mean, median, minimum, and maximum and the number of both missing and non-missing values for the variables ClassRank and GPA. Report the statistics to two decimal places. (Ref: Learning SAS by Example, Ron Cody, Chapter 16, Problem 1)

Input Data:


Solution:

 
Title 'Summary Statistics of ClassRank & GPA with two decimal pts';
 
proc means data=A15001.A01_College Mean Median Min Max NMiss N Maxdec=2;
    var ClassRank GPA;
run;
 
Title;

Output:

 

Problem 2:

Repeat Problem 1, except compute the desired statistics for each combination of Gender SchoolSize. Do this twice, once using a BY statement, and once using a CLASS statement.

Solution:

 
Title 'Grouped Summary Statistics of ClassRank & GPA with two decimal pts';
 
proc means data=A15001.A01_College Mean Median Min Max NMiss N Maxdec=2;
    Class Gender SchoolSize;
    var ClassRank GPA;
run;
 
Title;
 
/* Grouping with BY */
proc sort data=A15001.A01_College out=sorted_college;
    by Gender Schoolsize;
run;
 
Title 'Grouped Summary Statistics of ClassRank & GPA with two decimal pts';
 
proc means data=sorted_college Mean Median Min Max NMiss N Maxdec=2;
    by Gender SchoolSize;
    var ClassRank GPA;
run;
 
Title;

Output:




Learning:


  • Different ways of using PROC MEANS
  • Various options of PROC MEANS like MAXDEC
  • Grouping PROC MEANS Summary statistics


Popular Post

Blogger templates

Total Pageviews

Powered by Blogger.

- Copyright © nulldata -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -