Hi Guys,
Is it possible to create a sas program file (initially without any code) in a given folder (library)?
Note: I am not asking about creating a dataset, I need to create a blank sas program file during run time. Like invoking a macro should automatically create a filename.sas program in a folder.
Regards,
Ramakanth
Yes, a SAS program is stored as a text file on disk which you can create in a DATA step. Why do you want to do this?
data _null_;
file pgm "C:\Temp\MySASProgram.sas";
put "* A Comment;";
run;
Yes, a SAS program is stored as a text file on disk which you can create in a DATA step. Why do you want to do this?
data _null_;
file pgm "C:\Temp\MySASProgram.sas";
put "* A Comment;";
run;
I just wanted to create a file and write a program using a macro. Sorry if that wasn't clear in the initial question.
With macro code you usually don't need to write program code to a separate file, you can just generate the code from within a SAS macro just by calling it:
data _null_;
file pgm "C:\Temp\MySASProgram.sas";
put "* A Comment;";
run;
%include "C:\Temp\MySASProgram.sas";
* Above code does exactly the same thing as the following macro;
%macro comment;
* A Comment;
%mend comment;
%comment;
You do not even need to write to a file, just use call execute, and no file writing involved. Saved I/O.
Can't see any reason to do this, but a data-step can do this:
data _null_;
file "PATH_TO_FILE\empty.sas";
run;
One way to go:
data _null_;
stop;
file 'c:\temp\test2.sas';
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.