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;
1. Why not write into the correct folder directly?
2. Use function FCOPY() to copy the file to the new location.
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 */
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.