Question

Is there a way to run a one-liner in sas, or do I have to create a file? I'm looking for something like the -e flag in perl.

Was it helpful?

Solution

My favourite is using the -stdio option

Either:

sas -stdio

Then start typing. Or ...

echo "proc options; run;" | sas -stdio

OTHER TIPS

The Unix version of SAS was ported from MVS years ago and to make a long story short, the SAS executable does not import from STDIN. To make this work in Unix, merely alter slightly the previous suggestion into something like:

echo "your SAS code" > temp;sas -sysin temp

Hope this is helpful.

sas -initstmt '%put hello world ; endsas ;' 

sas -initstmt 'proc print data=sashelp.class; run ;' 

Off course this could also be:

sas -initstmt '%inc large_program.sas; endsas;'

Never having used sas, what I might try is something like:

echo <insert sas code here> | sas --execute-file -

Oftentimes applications will let you specify '-' as a file to have it read from STDIN. And 'echo' just prints its arguments out, and the | connects them together.

You could also use the -nodms option. This will give you a command line version of Base.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top