Tuesday, March 11, 2014

SAS- Proc Freq, Proc Mean etc.

Frequency and other statistical report using SAS programming


SAS PROGRAMS FOR ABSOLUTE BEGINNERS BY AJEET KUMAR

* Proc Freq Program Number: 1 ;
proc freq data = class ;
tables Gender * State * Income / norow nocol nopercent;
format Gender $Genderx. State $Statex. ;
run;

* Proc Freq Program Number: 2 ;
proc freq data = class ;
run;

* Proc Freq Program Number: 3 ;
proc freq data = class ;
tables Gender State ;
run;

* Proc Freq Program Number: 4 ;
proc freq data = class ;
tables _character_ ;
run;

* Proc Freq Program Number: 5 ;
proc freq data = class ;
tables _numeric_ ;
run;

* Proc Freq Program Number: 6 ;
proc freq data = class ;
tables _all_ ;
run;

* Proc Freq Program Number: 7 ;
proc freq data = class ;
tables Gender -- Height ;
run;

* Proc Freq Program Number: 8 ;
proc freq data = class ;
tables Gender State / nocum nopercent;
run;

* Proc Freq Program Number: 9 ;
proc freq data = class ;
tables Gender * State ;
run;

* Proc Freq Program Number: 10 ;
proc freq data = class ;
tables Gender * State / nocum nopercent;
run;

* Proc Freq Program Number: 11 ;
proc format;
value salrange low - 8000 = 'Very Low'
                        8000  <- 12000 = 'Low'
                        12000 <- 15000 = 'Middle'
                        15000 <- 20000 = 'High'
                        20000 <- high = 'Very High';
run;

proc freq data = class ;
tables Gender State income ;
format Income salrange. ;
run;

* Proc Freq Program Number: 12 ;
proc freq data = class ;
tables Gender State income / missing;
format Income salrange. ;
run;

* Proc Freq Program Number: 13 ;
data freqdata;
input color $ @@;
datalines;
2 2 1 1 1 1 1 4 4 4 2 2 1 1 1 1 1 4 4 4
2 2 2 2 3 4 1 2 2 4 3 3 4 4 1 1 3 3 4 4
3 3 3 3 3 2 2 2 2 2 2 2 1 1 1 1 1 3 2 3
4 4 4 4 4 2 4 1 4 1 2 2 1 1 1 1 1 4 3 2
2 2 4 1 1 1 1 4 2 3 2 2 1 1 1 1 1 4 3 3
;
run;
proc format;
value $colorlabel       '1' = 'Red' 
                              '2' = 'Green'
                              '3' = 'Yellow'
                              '4' = 'Blue'
                          other = 'Missing';

run;
proc freq data = freqdata;
format color $colorlabel. ;
run;

* Proc Freq Program Number: 14 ;
proc print data = freqdata;
format color $colorlabel. ;
run;

* Proc Freq Program Number: 15 ;
proc freq data = freqdata order=data;
format color $colorlabel. ;
run;

* Proc Freq Program Number: 16 ;
proc freq data = freqdata order=internal;
format color $colorlabel. ;
run;

* Proc Freq Program Number: 17 ;
proc freq data = freqdata order=formatted;
format color $colorlabel. ;
run;

* Proc Freq Program Number: 18 ;

proc freq data = freqdata order=freq;
format color $colorlabel. ;
run;

* Proc Freq Program Number: 19 ;
proc format;
value $Genderx 'M' = 'Male' 'F' = 'Female';
value $statex   'UK' = 'Uttarakhand'
                        'RS' = 'Rajsthan'
                        'MP' = 'MadhyaPradesh';
run;

proc freq data = class ;
tables Gender * State ;
run;

* Proc Freq Program Number: 20 ;
proc freq data = class ;
tables Gender * State * Income ;
format Gender $Genderx. State $Statex. ;
run;

No comments:

Post a Comment

Hot Topics