tags:

views:

327

answers:

4
+2  Q: 

sas one-liner

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.

A: 

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.

davr
+4  A: 

Hi, 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,

Mark

There are further command line options to control where the output and log go.
John Fouhy
+1  A: 

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;'

Henrik

+2  A: 

My favourite is using the -stdio option

Either:

sas -stdio

Then start typing. Or ...

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