Hi all,
I am using Base SAS and running codes in UNIX environment.
I am aware of X command, %SYSEXEC by which we can do some unix operations inside SAS.
ex:
X rm "./test.txt"; (to delete file test.txt)
Now I need to get in a value from runtime. Is there any command to get Value into SAS.
This will help me a lot as I can get values at run time.
I can write a shell script to get value and pass it to SAS but want to know if I can do it from inside code.
Thanks,
Karthik
Try to be more specific on how and what kind of values you want to pass to SAS.
Since SAS can read almost anything, there are tons of ways to pass/import values into SAS.
One way you might be interested in, is to import OS environment variable values - check out sysget.
Yes, %SYSGET will retrieve UNIX environment variables, and it may be all you need.
Another feature is the SYSPARM macro variable which is specified when launching SAS from the command line (-sysparm "value", option).
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000543608.htm
If what you need is access to the output of a system command (ls, cat, etc) submited within SAS then take a peak on pipe file commands:
Cheers from Portugal!
Daniel Santos @ www.cgd.pt
Wow, I did not know about the Filename-Feature for system commands.
Looks great. Thanks for sharing!
One - not so elegant - approach would be to write the output of your command into a file and then read this file in a Data-Step.
Like so:
x df -k | awk '{print $4}' > /somefolder/somefile.txt;
DATA work.data;
INFILE '/somefolder/somefile.txt' [...]
RUN;
Which would create data with all the free space in kbyte (in this example just the free space, not the folders or mount-points for which the free space was analysed. It does not make much sense like this, but then again it is just an example.)
Hope this helps.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.