Hey all,
I have wrote a sas program that takes in two sysparms upd_date and CSV.
I am automating these into autosys and running a shell script to execute my program
nohup sas program.sas -sysparm '$CSV $upd_date' -noterminal
I am wondering if there's anyway that you can read in a shell script defined variable into a sysparm call. Right now I read in my sysparms like so: %LET CSV = %SYSFUNC(TRIM(%QSCAN(&SYSPARM,1,%NRSTR(' '))));
So it is reading them in as a character $CSV and not TRANSACTION (which is what CSV is set to in shell script)
Does anyone have any tips or solutions to this, will this work or should I try a different route.
Use double quotes instead of single quotes in your command line. The unix shell is not expanding the variable reference and so the literal text '$CSV' will be passed to SAS as the value of SYSPARM macro variable. To test it just use ECHO command.
Compare:
echo -sysparm '$CSV $upd_date'
to
echo -sysparm "$CSV $upd_date"
%LET CSV = %SYSFUNC(TRIM(%QSCAN(&SYSPARM,1,%STR( ))));
Thanks for the reply, this way is still reading in the macro variables as $CSV in my sas code and not what was defined in the shell script.
CSV=TRANSACTION in shell script. Not sure if it's possible to bring in shell script defined variables into a sysparm command.
Thanks for the input though
Am not too familiar with your OS syntax, however if the variable needs to be de-referenced then it can't go in quotes as far as I know. Have you tried:
nohup sas program.sas -sysparm $CSV $upd_date -noterminal
If that doesn't work you may need to wrap in a batch file to echo out the full string.
Yeah that doesn't work either, I also tried concatenating full string to run into one variable which didn't work. I think I will take an approach to wrap in a batch file.
Thanks!
What happens if you use SYSGET on the values scanned from SYSPARM? You may also be able to skip this SYSPARM and just use SYSGET in your code.
I also tried using SYSGET yesterday and wasn't working.. was still showing up as $CSV unfortunately
Did you remove the $sign?
Keep it as: nohup sas program.sas -sysparm "$CSV $upd_date" -noterminal
The change to double quotes makes it work.
"Macro variable CSV resolves to TRANSACTION"
"Macro variable upd_date resolves to 4"
I was referring to SYSGET i.e. sysget('$CSV') vs sysget('CSV');
shell command EVAL might fix it
eval "nohup sas program.sas -sysparm '$CSV $upd_date' -noterminal"
Use double quotes instead of single quotes in your command line. The unix shell is not expanding the variable reference and so the literal text '$CSV' will be passed to SAS as the value of SYSPARM macro variable. To test it just use ECHO command.
Compare:
echo -sysparm '$CSV $upd_date'
to
echo -sysparm "$CSV $upd_date"
Can't believe I didnt think of that to try, thanks for everyone's input and help!
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.