BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
carmong
Obsidian | Level 7

I am attempting to create a table with only the row percentages. So far I have written code that has removed the column numbers and column percent's which has given me the table below:

 

proc freq data=pairs;
table admissiondate*def1 /NOCOL NOpercent out=freqmonth&today. outpct;
format admissiondate MONYY.;
run;

 

admissiondate def1    
   Associated Associated Total
  illness non illness  
20-Jan 1 0 1
  100 0  
20-Feb 5 1 6
  83.33 16.67  
20-Mar 780 63 843
  92.53 7.47  
20-Apr 2770 276 3046
  90.94 9.06  
20-May 2128 380 2508

 

How can I write a code which will provide me a table with only the row percent's like the one below?

admissiondate def1  
   Associated Associated
  illness non illness
20-Jan 100 0
20-Feb 83.33 16.67
20-Mar 92.53 7.47
20-Apr 90.94 9.06
20-May 84.85 15.15

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

NOFREQ option needs to be added.

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_freq_syntax08.htm#procstat....

 


@carmong wrote:

I am attempting to create a table with only the row percentages. So far I have written code that has removed the column numbers and column percent's which has given me the table below:

 

proc freq data=pairs;
table admissiondate*def1 /NOCOL NOpercent out=freqmonth&today. outpct;
format admissiondate MONYY.;
run;

 

admissiondate def1    
   Associated Associated Total
  illness non illness  
20-Jan 1 0 1
  100 0  
20-Feb 5 1 6
  83.33 16.67  
20-Mar 780 63 843
  92.53 7.47  
20-Apr 2770 276 3046
  90.94 9.06  
20-May 2128 380 2508

 

How can I write a code which will provide me a table with only the row percent's like the one below?

admissiondate def1  
   Associated Associated
  illness non illness
20-Jan 100 0
20-Feb 83.33 16.67
20-Mar 92.53 7.47
20-Apr 90.94 9.06
20-May 84.85 15.15

 

 

 

 

 


 

View solution in original post

2 REPLIES 2
Reeza
Super User

NOFREQ option needs to be added.

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_freq_syntax08.htm#procstat....

 


@carmong wrote:

I am attempting to create a table with only the row percentages. So far I have written code that has removed the column numbers and column percent's which has given me the table below:

 

proc freq data=pairs;
table admissiondate*def1 /NOCOL NOpercent out=freqmonth&today. outpct;
format admissiondate MONYY.;
run;

 

admissiondate def1    
   Associated Associated Total
  illness non illness  
20-Jan 1 0 1
  100 0  
20-Feb 5 1 6
  83.33 16.67  
20-Mar 780 63 843
  92.53 7.47  
20-Apr 2770 276 3046
  90.94 9.06  
20-May 2128 380 2508

 

How can I write a code which will provide me a table with only the row percent's like the one below?

admissiondate def1  
   Associated Associated
  illness non illness
20-Jan 100 0
20-Feb 83.33 16.67
20-Mar 92.53 7.47
20-Apr 90.94 9.06
20-May 84.85 15.15

 

 

 

 

 


 

ballardw
Super User

Or perhaps a different procedure.

 

One way though the output data set will look a bit different. For one thing the percentage variable will have a different name because the data sets that Tabulate creates can have a lot more variables than the out= is allowed by Proc Freq.

proc tabulate data=pairs out=freqmonth&today.;
   class admissiondate def1;
   format admissiondate monyy.;
   table admissiondate,
         def1*rowpctn=' ';
run;

Note the rowpctn=' ' has a blank label for the statistic so the results won't show RowPctN in each column. Might not want to so if you were including other statistics like the ColPctN (freq column pct)

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 249 views
  • 4 likes
  • 3 in conversation