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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.