BookmarkSubscribeRSS Feed
sam_sas2
Obsidian | Level 7

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! 🙂

2 REPLIES 2
LeonidBatkhan
Lapis Lazuli | Level 10

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.

ballardw
Super User

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.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 822 views
  • 0 likes
  • 3 in conversation