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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.