Pages

Friday 2 October 2015

SAS Problems - 2

In this blog post I will be presenting problems of  SAS from a textbook written by Ron Cody.
The flow will be as such
         
  • Chapter
  • Problem statement
  • Code
  • Result
  • Learning - what I have learnt from this problem



CHAPTER: 16

PROC MEANS (or PROC SUMMARY) primarily as a way to generate summary reports, reporting the sums and means of your numeric variables. However, these procedures are much more versatile and can be used to create summary data sets that can then be analysed 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. 



CODE : 





 
libname A15033 "/folders/myfolders";
options fmtsearch=(A15033);

 title "Statistics on the College Data Set";
 proc means data=A15033.college
                    n
                    nmiss
                    mean
                    median
                    min
                    max
                    maxdec=2;
 
 var ClassRank GPA;
 run;
RESULT


LEARNING :
I had an understanding of how Proc means, n , nmiss , maxdec work.  






CHAPTER 17;

PROC FREQ can be used to count frequencies of both character and numeric variables, in one-way, two-way, and three-way tables. In addition, you can use PROC FREQ to create output data sets containing counts and percentages.

PROBLEM 2 :

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.


CODE

title "frequencies from blood data set";
proc freq data=A15033.blood;
tables Gender BloodGroup Age/ nocum nopercent;
run;



RESULT :


LEARNING :

I had an understanding of how Proc Freq


CHAPTER 17


PROC FREQ can be used to count frequencies of both character and numeric variables, in one-way, two-way, and three-way tables. In addition, you can use PROC FREQ to create output data sets containing counts and percentages.

PROBLEM  3;

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.


CODE :




title "Creating a 3 way table for college";
proc freq data=A15033.college;
tables Gender * Scholarship * SchoolSize/ nocol norow nopercent;
run;


RESULT :


LEARNING


I had an understanding of how proc freq works



CHAPTER 18

PROC TABULATE is an underused, under-appreciated procedure that can create a wide variety of tabular reports, displaying frequencies, percentages, and descriptive statistics (such as sums and means) broken down by one or more CLASS variables.


PROBLEM 4:

Using the SAS data set College, write the appropriate PROC TABULATE statements to produce the given table.

CODE :

title "College Demography";
proc tabulate data=A15033.college;
class Gender Scholarship SchoolSize;
tables Gender Scholarship All;
Schoolsize/rts=15;
keylabel n=" ";
 run;
RESULT


LEARNING

I had an understanding of how to use PROC Tabulate for table forming using "Class", "Tables"  and "Keylabel" statement.


CHAPTER 19;
The Output Delivery System, abbreviated as ODS.  The outputs were difficult to incorporate into other documents, such as Microsoft Office Word or Microsoft Office PowerPoint. Hence this ODS brought about a revolution by actually allowing SAS enthusiasts to save the outputs in the desired format.

PROBLEM 5;
Using the SAS data set Test Score, write the appropriate ODS output path along with PROC PRINT to produce the required output.


CODE :


ods html file ="/folders/myfolders/ODS_Outputs/prog1.html";

title "Test Score Listings";
proc print data=A15033.Test_Scores;
id ID; var Score1-Score3;
run;
proc means data=A15033.Test_Scores n max min mean median maxdec=1;
var Score1-Score3;
run;
RESULT



The usage of  'ODS Html file' for stating the output path and generating an html output


LEARNING

I had an understanding of how to use Proc Print with ODS.


No comments:

Post a Comment