BookmarkSubscribeRSS Feed
kaziumair
Quartz | Level 8

Hi everyone , 

1) I have to create pdf files of the log generated by a sas program which runs on a monthly basis.

2) Send the created pdf file to a newly created folder .

 

This is an example structure of the folder :

Jan2021

       log.pdf

 

I have figured out individually , how to create the pdf and the new directory . But I am unable to figure out how to send the pdf to the new folder . Please help.

 

Code to create pdf:

filename test "C:/myfolder/new.log";

proc printto log=test new;
run;

proc print data=sashelp.cars;
run;

proc printtto;
run;

proc document name=mynewdoc(write);
import textfile=test to logfile;
run;
ods pdf file="C:/myfolder/myfile.pdf";
replay;
run;
ods pdf close;
quit;

 

code to create new directory:

data _null_;
year=year(today());
dir_name = put(today(),monname3.)!!"-"!!put(year,4.);
NewDirectory=dcreate(dir_name,'C:/mynewfolder');
run;

 

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

1. Why not write into the correct folder directly?

2. Use function FCOPY() to copy the file to the new location.

 

japelin
Rhodochrosite | Level 12

I think you can save the name of the folder you want to create first in a macro variable and use it in the ods pdf statement.

 

at first submit this.

data _null_;
  dir_name = put(today(),monname3.)!!"-"!!put(year(today()),4.);
  call symput('NEWDIR',"C:/mynewfolder/"||dir_name);/* save in macro variable */
  NewDirectory=dcreate(dir_name,'C:/mynewfolder');
run;

next submit your code to create pdf which fix below.

ods pdf file="&NEWDIR/myfile.pdf";/* create pdf directly */

 

 

 

 

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 898 views
  • 0 likes
  • 3 in conversation