Hi All,
I'm currently using the following proc tabulate code to generate count and descriptive statistics across Type and Origin.
proc tabulate data= sashelp.cars; class Type origin make model / style=[foreground=blue just=c] missing; var msrp; table ((make model)* (N)) ((msrp) * (NMISS N MEAN MEDIAN MIN MAX)), ALL Type origin/ misstext='0'; run;
I am trying to replicate the same thing in proc report, however, when I group the make and model, the values end up next to each other and not one below another.
Is this even possible in proc report?
Any sort of help would help a lot!
Thanks in advance!
P.S. I tried the BREAK statement in PROC REPORT but that didn't pan out.
Thanks in advance! 🙂
Hi sam_sas2,
For PROC REPORT you can control columns hierarchy, see the following example from Report Customization Using PROC REPORT:
PROC REPORT DATA=SASHELP.SHOES NOWD;
COLUMN('Global shoe sales in USD'('Regional Shoe sales' REGION PRODUCT SUBSIDIARY) ('In USD only' SALES));
RUN;
Hope this helps.
Proc report doesn't want to use more than one variable/statistic in a column. What are you needing to do that you think you want to switch to Report since you are going to add a fair amount of work to do something "unnatural" for Report.
You could manage this, possibly, by transposing the data so that the source data has a new variable that holds the value of the variable name, such as Make and Model, and a new variable to hold the actual values.
Such as
data changeclass; set sashelp.cars; /* this array has the elements you want to stack must be of the same type*/ array a (*) make model; do i=1 to dim(a); varname =vname(a[i]); value = a[i]; output; end; drop i make model; run;
But that will duplicate all of the other variables. So statistics you request for Msrp would be incorrect.
So you would need to set most of those other variables to missing. Depending on what you expected to do there are likely to be lots of complications.
You could use the Varname and Value created variables as group variables but that may not be sufficient.
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.