BookmarkSubscribeRSS Feed
venkatavmalla
Calcite | Level 5

In my output some roll numbers are there with each roll number 10 to 30 transactions are there, i want to export each roll number as a pdf file, can anybody help to write macro or sas code to export each roll number transactions into one pdf

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi:
If you use BY group processing, SAS and ODS will automatically make a PDF file for every BY group. Consider this code, which makes 1 PDF for every age when age is used as a BY variable with a BY statement.

 

proc sort data=sashelp.class out=class;
  by age;
  where age in (12, 13, 14);
run;
 
ods pdf file='c:\temp\bygrp_age1.pdf' newfile=bygroup;
 
proc print data=class;
by age;
var age name sex height weight;
run;
 
ods pdf close;

For example, the above code makes 3 PDF files, one for each AGE -- and changes the name for each file it makes:

 

Age 12 c:\temp\bygrp_age1.pdf

Age 13 c:\temp\bygrp_age2.pdf

Age 14 c:\temp\bygrp_age3.pdf

 

  You only need a SAS macro approach if you want to control the names of the output files being created. Otherwise NEWFILE=BYGROUP does it for you automatically.

 

  If you need a macro program, you will find a relevant example in this paper: https://support.sas.com/resources/papers/proceedings13/120-2013.pdf 


cynthia

venkatavmalla
Calcite | Level 5

Thank you for your solutions it is working, but please help on one more..  i want to save each file with that age and person name automatically can you help on this

Cynthia_sas
SAS Super FREQ
Hi:
Look at the paper link that I posted. In that paper, it shows how to make a macro variable that you can use for the file name. By extending those concepts to select on age and person, you can make a macro program to do what you want. It would NOT actually make sense with SASHELP.CLASS to write a macro by AGE and PERSON (NAME) because there is only 1 person for every name, but multiple people for every age.

To do what you want, you need to understand both macro variables and macro programs. The paper link I posted has enough information to get you started.

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
  • 6334 views
  • 1 like
  • 2 in conversation