BookmarkSubscribeRSS Feed
KarthikR
Calcite | Level 5

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

4 REPLIES 4
LinusH
Tourmaline | Level 20

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.

Data never sleeps
DanielSantos
Barite | Level 11

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).

More on this here:

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:

http://support.sas.com/documentation/cdl/en/hostunx/63053/HTML/default/n1ceb0xedanuj3n19l3g73awk1wf....

Cheers from Portugal!

Daniel Santos @ www.cgd.pt

mfab
Quartz | Level 8

Wow, I did not know about the Filename-Feature for system commands.

Looks great. Thanks for sharing!

mfab
Quartz | Level 8

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3270 views
  • 1 like
  • 4 in conversation