Hi,
I have used proc freq on several variables cross referencing a year variable:
Proc Freq data=have;
tables Var*year
run;
Instead of the standard proc freq output, which stacks Freq, Col Percent, Row percent, etc., I'd like to have a table that joins the freq and Col percent into a single cell (or at least appear that way visually). Here is an example hand keyed from excel. I'd like to have sas output it in the format I need, rather than reentering the sas output into excel each time.
Gender | 2012 | 2013 | 2014 | 2015 | 2016 |
Male | 25 (12.5%) | 50 (25%) | 75 (37.5%) | 90 (45%) | 100 (50%) |
Female | 175 (87.5%) | 150 (75%) | 125 (62.5%) | 110 (55%) | 100 (50%) |
Thanks!
Chris
There isn't a default way to do this, you need to create some custom code to generate the table you want.
Program it once in SAS, if you're interested in writing the code look up a Cynthia Zender Paper called creating complex reports.
If you just wanr code, look up Summary tables in lexjansen.com, there are a lot of written papers on this topic.
In order to create a complex report, First PROC SQL, then PROC TRANSPOSE. proc sql; create table temp as select sex,age,cats(count(*),'(', put( count(*)/(select count(*) from sashelp.class where sex=a.sex) ,percent7.2), ')') as value from sashelp.class as a group by sex,age ; quit; proc transpose data=temp out=want prefix=age; by sex; var value; id age; run; proc print noobs;run;
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.
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.