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 |
NOFREQ option needs to be added.
@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
NOFREQ option needs to be added.
@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
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)
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.