BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
75063
Obsidian | Level 7

Is it possible to concatenate two or more proc reports? 

 

 

 

The proc reports look like these -

 

data have;
input brand $ Freq Freq1 perchange;
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;

 

proc report data=have nowd out=abs
style(summary)=Header;
title 'Proc Report Crosstab Report';
column brand
('Enrollment' Freq Freq1 perChange);
define brand / group "Enrollment by Residency";
rbreak after / summarize;
run;


data have1;
input cars $ Freq Freq1 perchange;
datalines;
A 4 1 9
B 6 0 5
C 8 1 6
D 1 6 8
E 7 4 4
F 6 5 1
;
run;


proc report data=have1 nowd out=abs1
style(summary)=Header;
title 'Proc Report Crosstab Report';
column cars 
('Enrollment1' Freq Freq1 perChange);
define brand / group "Enrollment1 by College";
rbreak after / summarize;
run;

 

 

 

 

So the two Proc reports have out "abs" and "abs1". 

 

My report should output the two reports one after then other in the order and have two blank spaces between them. I have attached a sample report that I would need as an output. 

 

 When I use the following code my output is not like the one that I desire (attached with the post)  

 

proc report data=have nowd out=abs
style(summary)=Header;
title 'Proc Report Crosstab Report';
column brand
('Enrollment' Freq Freq1 perChange);
define brand / group "Enrollment by Residency";
rbreak after / ;
column brand
('Enrollment1' Freq Freq1 perChange);
define brand / group "Enrollment1 by college";
rbreak after /;
run;

 

 

 

 

 

 

Can someone please suggest a possible solution.  

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:
There is NOT any ODS XLS destination. You need to use either ODS EXCEL or ODS TAGSETS.EXCELXP. Like this:

 

SAS OnDemand for Academics

ods excel file='/home/youruserid/all_output/report.xlsx';
...more code ...;
ods excel close;
  
ods tagsets.excelxp file='/home/youruserid/all_output/report.xml';
...more code ...;
ods tagsets.excelxp close;

 

SAS University Edition

ods excel file='/folders/myfolders/all_output/report.xlsx';
...more code ...;
ods excel close;
  
ods tagsets.excelxp file='/folders/myfolders/all_output/report.xml';
...more code ...;
ods tagsets.excelxp close;

Note that the FILE EXTENSIONS are important.

ODS EXCEL --only-- creates .XLSX (2007 Office Open XML format for Excel) files and

ODS TAGSETS.EXCELXP works best when you use the file extension of .XML (2003 Spreadsheet Markup Language XML files).

Cynthia

View solution in original post

8 REPLIES 8
Cynthia_sas
SAS Super FREQ
Hi:
Other than the fact that you might have more than "2 spaces" between the 2 tables, what is wrong with your existing reports? And, how do you measure 2 spaces?

What is your destination of choice? RTF, PDF, HTML? Or???

I don't understand the purpose of creating output datasets ABS and ABS1 -- do you have something else to do with those datasets?

Cynthia
75063
Obsidian | Level 7

Hi Cynthia, 

 

Thankyou for your reply. 

 

I wanted the proc reports for the two datasets  'have' and 'have1' to be output one after the other, rather than merge horizontally as it was with the code I had provided.  

 

The two data sets are completely independent of each other.  

 

By  'Blank' i was basically asking how to insert spaces between observations.  For example if a Proc report has 7 observations (independent of each other, made by concatenating from other data) how can I insert a blank  between the 2nd. and 3rd. observation.  

 

Thank you! 

Cynthia_sas
SAS Super FREQ

Hi:

  I don't understand the code that you've posted. If I run all of your posted code, here's what I get:

what_orig_code_produces.png

 

  I don't see any place that you're using ABS and ABS1 (so I didn't bother creating them). I used your posted data.

 

  The last PROC REPORT that you posted will NOT work to place one table AFTER the other. Your 2 COLUMN statements are not doing what you say you want because PROC REPORT doesn't place one column statement after the other, it places everything on 1 report row -- or tries to.

 

  You still have not said what your final destination of interest is. When I use your two original PROC REPORTS with PDF and STARTPAGE=NO, this is what I get:

with_pdf.png

 

Which looks to me very close to what you describe.

 

Cynthia

75063
Obsidian | Level 7

Thank you for your reply. 

 

However, i am using SAS on demand for academics so do not have the privilege of a ods output.  (it gives me an error as:            ERROR: Insufficient authorization to access /pbr/biconfig/940/Lev1/SASApp/c:\temp\you.pdf)

 

I would like the output to be in sas studio , just as a proc print output.  

 

Is there a way to get the same output as you had in the reply in the SAS studio environment?  

 

Regards,

R

Cynthia_sas
SAS Super FREQ

Hi:
You CAN use SAS OnDemand for Academics with ODS. Even if you're using SAS Studio or Enterprise Guide. You just have to make a folder in your Files area and then write the output there.

For example, on my SAS OnDemand for Academics, I have a folder called all_output under my /home directory. Or, on SAS University Edition, I might have a folder called all_output on my /folders/myfolders location. In either case, this is how I would create ODS output:
1) Make a folder called all_output in the correct location where you have WRITE access

2) Write the appropriate code
2a) SAS OnDemand for Academics:

ods pdf file='/home/youruserid/all_output/report.pdf';
...more code ...;
ods pdf close;
 
ods rtf file='/home/youruserid/all_output/report.rtf';
...more code ...;
ods rtf close;
 
ods html path='/home/youruserid/all_output' file='report.html';
...more code ...;
ods html close;

2b) SAS University Edition in a Virtual Machine:

ods pdf file='/folders/myfolders/all_output/report.pdf';
...more code ...;
ods pdf close;
 
ods rtf file='/folders/myfolders/all_output/report.rtf';
...more code ...;
ods rtf close;
 
ods html path='/folders/myfolders/all_output' file='report.html';
...more code ...;
ods html close;

Then, after the output is created, you have to navigate to that location and open or download the file from the output folder.


Cynthia

75063
Obsidian | Level 7
Thank you for the suggestion.
I wanted to read the file in the Files(Home) folder. The properties of this folder tells me that the path is : \home\myname0

So should the ods statement read like this? -
ods xls file= "\home\myname0\you.xls" startpage=no ;

and should end like
ods xls close;

However, it is still giving me an error - ERROR 180-322: Statement is not valid or it is used out of proper order.

Is this because xls is not a output type?

Cynthia_sas
SAS Super FREQ

Hi:
There is NOT any ODS XLS destination. You need to use either ODS EXCEL or ODS TAGSETS.EXCELXP. Like this:

 

SAS OnDemand for Academics

ods excel file='/home/youruserid/all_output/report.xlsx';
...more code ...;
ods excel close;
  
ods tagsets.excelxp file='/home/youruserid/all_output/report.xml';
...more code ...;
ods tagsets.excelxp close;

 

SAS University Edition

ods excel file='/folders/myfolders/all_output/report.xlsx';
...more code ...;
ods excel close;
  
ods tagsets.excelxp file='/folders/myfolders/all_output/report.xml';
...more code ...;
ods tagsets.excelxp close;

Note that the FILE EXTENSIONS are important.

ODS EXCEL --only-- creates .XLSX (2007 Office Open XML format for Excel) files and

ODS TAGSETS.EXCELXP works best when you use the file extension of .XML (2003 Spreadsheet Markup Language XML files).

Cynthia

75063
Obsidian | Level 7

Good day Cynthia, 

 

Thank you for the detailed explanation.  It really worked perfect for my problem.   

 

Regards,

R

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 8 replies
  • 2521 views
  • 0 likes
  • 2 in conversation