Does the SAS command line command have an option to override a SAS variable?
SAS Code in run_sas_code.sas
%let my_path=/default/path/;
%put &my_path.;Command line command:
sas /home/users/me/run_sas_code.sas -log /home/users/me/log.log
I want something like that:
sas /home/users/me/run_sas_code.sas -log /home/users/me/log.log --my_path=/new/path/value/
Thanks!
When you use -sysparm= on the commandline, the text following the -sysparm= will be available in automatic macro variable &sysparm in the SAS session. Note that you can't change the name of the macro variable.
A more flexible way for handing parameters to batch programs is the use of operating system environment variables. Consider this shell script:
export VAR1=xxxxxx
export VAR2=yyyyy
sas program.sas
and this program:
%let var1=%sysget(VAR1);
%let var2=%sysget(VAR2);
data mylib.test;
var1 = "&var1";
var2 = "&var2";
run;
You will find the contents ("xxxxxx" and "yyyyy") in dataset mylib.test.
If you want to change the value of a macro variable, you can do so in the AUTOEXEC file, and then it will apply to the entirety of your SAS session; alternatively you could change the value of the macro variable in the first command of your SAS session.
When you use -sysparm= on the commandline, the text following the -sysparm= will be available in automatic macro variable &sysparm in the SAS session. Note that you can't change the name of the macro variable.
A more flexible way for handing parameters to batch programs is the use of operating system environment variables. Consider this shell script:
export VAR1=xxxxxx
export VAR2=yyyyy
sas program.sas
and this program:
%let var1=%sysget(VAR1);
%let var2=%sysget(VAR2);
data mylib.test;
var1 = "&var1";
var2 = "&var2";
run;
You will find the contents ("xxxxxx" and "yyyyy") in dataset mylib.test.
For a discussion and example, see "How to pass parameters to a SAS Program."
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 save with the early bird rate—just $795!
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.