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;
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?
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;
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.
Ready to level-up your skills? Choose your own adventure.