BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

What is the way to convert this proc tabulate code into proc report?

There is only one change in the required output.

I want that in each row in output there will be value of Origin.

The reason is that the real report is very long and it is difficult for users to see what is the origin value for each row.

Proc tabulate data =SASHelp.cars(where=( Origin in ('Asia' ,'Europe')
and  Type in ('Hybrid','Suv','Sedan')))
 format=comma21.;
Class Origin  Make  Cylinders   Type  ;
Var Invoice;
Table Origin=""*Make='',
Type='Nr Customers'*(Cylinders='' All)*N=''  
all=''*N='TOTAL'

Type='Total Revenue'*(Cylinders='' All)*SUM=''*Invoice=''  
all=''*Invoice='TOTAL'
/box='Make/Origin' misstext='0'  nocellmerge;
format  Cylinders fCylinders.;
Run;
2 REPLIES 2
andreas_lds
Jade | Level 19

This questions seems to be related to https://communities.sas.com/t5/SAS-Programming/proc-tabulate/m-p/678816. @RichardDeVen provided a solution with proc report in the other thread. Why was it not acceptable?

Shmuel
Garnet | Level 18

Though it is not what you asked (converting to proc report) but it may fit your needs, 

please check next code and result:

proc summary data=SASHelp.cars(where=( Origin in ('Asia' ,'Europe') and  
                                Type in ('Hybrid','Sedan')))
             nway    missing ;
	 Class Origin  Make  Type Cylinders ;
	 Var Invoice;
	 output out=summed(drop=_type_ rename=(_freq_=Nr_Customers)) n=cyl sum=inv;
	 format  Cylinders fCylinders.;
run;
Proc tabulate data =summed;
	Class Origin  Make  Cylinders   Type  ;
	Var cyl inv;
	Table Origin=""*Make=''*type="",
	(All='Total' Cylinders)*(cyl='Nr. Customers' inv='Invoice')*sum=''*f=comma21.
	/box='Make/Origin/Type' misstext='0'  nocellmerge;
	
	format  Cylinders fCylinders.;
Run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1019 views
  • 0 likes
  • 3 in conversation