Help using Base SAS procedures

Obtaining cum. freqs for all possible outcomes in TABLES variable for PROC FREQ

Reply
Occasional Contributor
Posts: 13

Obtaining cum. freqs for all possible outcomes in TABLES variable for PROC FREQ

I am trying to build a dataset that shows the cumulative % of "bads" across 10 different buckets using PROC FREQ.  I'm running into a problem for the buckets where there are zero "bads."  SAS outputs what I've labeled below as "Table 1" where what I need is "Table 2."  Basically, the difference that I'm trying to solve is to have SAS output that 80% - 90% bucked and output the same Cumulative Bad % from the bucket above it.  Are there any options in PROC FREQ to do this?  If not, what is the best alternative approach?  Thanks!

TABLE 1:

PercentileBadsCum. Bad %
0 - 10%520.8%
10% - 20%645.8%
20% - 30%254.2%
30% - 40%158.3%
40% - 50%370.8%
50% - 60%175.0%
60% - 70%283.3%
70% - 80%291.7%
90% - 100%2100.0%


TABLE 2:

PercentileBadsCum. Bad %
0 - 10%520.8%
10% - 20%645.8%
20% - 30%254.2%
30% - 40%158.3%
40% - 50%370.8%
50% - 60%175.0%
60% - 70%283.3%
70% - 80%291.7%
80% - 90%091.7%
90% - 100%2100.0%
PROC Star
Posts: 7,363

Obtaining cum. freqs for all possible outcomes in TABLES variable for PROC FREQ

Take a look at the following SAS-L thread: http://listserv.uga.edu/cgi-bin/wa?A2=ind1107e&L=sas-l&D=0&P=3180

Respected Advisor
Posts: 3,777

Re: Obtaining cum. freqs for all possible outcomes in TABLES variable for PROC FREQ

Another complete example with data.  Uses CLASSDATA option. 

proc rank data=sashelp.heart groups=10 out=smoke;

   var Smoking;

   run;

data class;

   if 0 then set smoke;

   do smoking=0 to 9;

      output;

      end;

   stop;

   run;

proc summary data=smoke nway classdata=class;

   class smoking;

   output out=summary;

   run;

proc freq;

   tables smoking;

   weight _freq_ / zeros;

   run;

          Values of Smoking Were Replaced by Ranks

                                    Cumulative    Cumulative

Smoking    Frequency     Percent     Frequency      Percent

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

      0           0        0.00             0         0.00

      1           0        0.00             0         0.00

      2        2501       48.35          2501        48.35

      3           0        0.00          2501        48.35

      4         113        2.18          2614        50.53

      5         466        9.01          3080        59.54

      6         576       11.13          3656        70.67

      7         921       17.80          4577        88.48

      8         125        2.42          4702        90.90

      9         471        9.10          5173       100.00


					
				
			
			
				
			
			
			
			
			
			
			
		
Occasional Contributor
Posts: 13

Obtaining cum. freqs for all possible outcomes in TABLES variable for PROC FREQ

Easy enough.  Using the preloadfmt / completetypes options in PROC Summary and then running that dataset through PROC Freq seems to get me exactly where I need.  Thanks for the link!    

Ask a Question
Discussion stats
  • 3 replies
  • 366 views
  • 0 likes
  • 3 in conversation