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

Dear all:

I just joined the community and I hope to learn and share with you as much as possible.

I have one question to start:

I need to create as many reports as categories are in the BY statement of a PROC FREQ (there will be around 30), and export the PDF output as an individual PDF file (this is, one PDF file for each category in the BY statement).

So far, I've come to this syntax, which exports only an aggregated file instead of for each category in the BY statement:


ODS PDF STYLE=Styles.SASweb FILE='C:\S1_out.pdf';

PROC FREQ DATA=WORK.Labels_Export_CMS;
TITLE "Finalized Cases";
TABLES
IntervierName*DispositionCode / nocol nopercent;
WHERE status=2;
BY Supervisor;
RUN;

ODS PDF CLOSE;

Ideally, I would need to do this as efficient as possible (hopefully, not making one syntax as the one above for each of the 30 cases), since I'll need to generate this information from the same database (same structure, new information), weekly.

Thank you very much.

Rafa

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Try the newfile=bygroup option in the ODS PDF statement. I don't know if theres's a way to control the filename though.

proc sort data=sashelp.class out=class;

by sex;

run;

ods pdf file="C:\_LocalData\Summary.pdf" style=seaside newfile=bygroup;

proc freq data=class;

by sex;

table age;

run;

ods pdf close;

View solution in original post

3 REPLIES 3
Reeza
Super User

Try the newfile=bygroup option in the ODS PDF statement. I don't know if theres's a way to control the filename though.

proc sort data=sashelp.class out=class;

by sex;

run;

ods pdf file="C:\_LocalData\Summary.pdf" style=seaside newfile=bygroup;

proc freq data=class;

by sex;

table age;

run;

ods pdf close;

Rafa
Calcite | Level 5

Thank you very much! This works just fine for what I need to do.

I can work around a way to solve the name issue (since it is sorted, I could link the variable name given by the newfile=bygroup statement with the actual value in a separate table). If I find a SAS solution to it, I'll post it here as well.

:smileygrin:

Cynthia_sas
SAS Super FREQ

Hi, when you use NEWFILE=, the names are always numbered versions of the original FILE= value. You can't control the names, unless you "macro-ize" your code to supply a specific name.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 940 views
  • 1 like
  • 3 in conversation