Hi All,
I am using SAS on demand for academics so I do not have access to ods output function.
I have two proc report outputs from two data frames.
the data frames are "test" and "test1"-
data test;
input brand $ Freq Freq1 COUNT;
datalines;
A 2 3 8
B 3 5 4
C 4 6 2
D 5 1 1
E 6 5 8
F 7 7 9
;
run;
data test1;
input cars $ Freq Freq1 COUNT;
datalines;
g 4 1 9
h 6 0 5
i 8 1 6
j 1 6 8
k 7 4 4
l 6 5 1
;
run;
The two proc reports that I get from the above data frames are as below -
proc report data=test nowd out=abs
style(summary)=Header;
title 'test';
column brand
('Enrollment' Freq Freq1 COUNT);
define brand / group "Enrollment by Residency";
rbreak after / summarize;
run;
proc report data=test1 nowd out=abs
style(summary)=Header;
title 'test1';
column cars
('Enrollment' Freq Freq1 COUNT);
define cars / group "Enrollment by type";
rbreak after / summarize ;
run;
The output of these reports are attached as "Output" . However, my desired output has sub headings in between the observations as in the attachment "Desired output"
Looking for some guidance on changing my "Output" to the "Desired output".
Thank you!
Where do Sub1 and Sub2 come from? It's not shown in your samples. For the code to be dynamic and account for that the logic has to flow from the data.
data test; infile cards truncover; input GROUP_VAR $ brand $ Freq Freq1 COUNT; datalines; SUB1 A 2 3 8 SUB1 B 3 5 4 SUB1 C 4 6 2 SUB2 D 5 1 1 SUB2 E 6 5 8 SUB2 F 7 7 9 ; run; proc tabulate data=test; class group_var brand / order=data missing; var freq freq1 count; table group_var=''*brand='', freq*sum='' freq1*sum='' count*sum=''/misstext=''; run; proc report nowd data=test; col group_var brand freq freq1 count; define group_var / group noprint format=$8.; define brand/order; define freq/ sum; define freq1 / sum; define count / sum; break before group_var / skip; compute before group_var/ style={cellheight=8pt font_size=12pt just=left}; line group_var $100.; endcomp; run;
It looks like you will need a "Compute After" but I'm not sure exactly how to implement that as i don't know how your car and brand groups are defined.
Check page 5 of this PDF where they use a format statement to define the groups;
http://www.excursive.net/sas/ProcReportPaper.pdf
proc format;
value $Continent
'U.S.A.', 'CANADA'= 'NA'
'GERMANY' = 'EU';
run;
proc report data=smallprod
nowindows missing headline;
column country region predict actual;
define country / group format=$continent. width=7;
define region / group;
run;
prints:
Country Region PREDICT ACTUAL
-------------------------------------------
EU EAST 1,810.00 1,592.00
WEST 2,283.00 2,224.00
NA EAST 3,369.00 3,979.00
WEST 2,489.00 3,388.00
Probably need to do something like that for your brand/car groups and then use that format in "Define" and "Compute After".
Sorry, kind of lazy. marginally helpful response, but maybe it will be what you need.
I think you should consider combining your data and try PROC TABULATE instead.
@75063 wrote:
Thank you for your reply. Here all the observations in cars and brand are independent to each other as they have been concatenated from various data sets. So we are unable to use a summary or grand total.
Where do Sub1 and Sub2 come from? It's not shown in your samples. For the code to be dynamic and account for that the logic has to flow from the data.
data test; infile cards truncover; input GROUP_VAR $ brand $ Freq Freq1 COUNT; datalines; SUB1 A 2 3 8 SUB1 B 3 5 4 SUB1 C 4 6 2 SUB2 D 5 1 1 SUB2 E 6 5 8 SUB2 F 7 7 9 ; run; proc tabulate data=test; class group_var brand / order=data missing; var freq freq1 count; table group_var=''*brand='', freq*sum='' freq1*sum='' count*sum=''/misstext=''; run; proc report nowd data=test; col group_var brand freq freq1 count; define group_var / group noprint format=$8.; define brand/order; define freq/ sum; define freq1 / sum; define count / sum; break before group_var / skip; compute before group_var/ style={cellheight=8pt font_size=12pt just=left}; line group_var $100.; endcomp; run;
I am using SAS on demand for academics so I do not have access to ods output function.
Are you sure about that? Is there some feature you tried that didn't work?
You have to specify the file paths correctly and you can download the files afterward but it works perfectly fine AFAIK. See the image below, I've XXXX out my name from the file path.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: