6

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.

David Nehme
  • 21,379
  • 8
  • 78
  • 117

5 Answers5

8

My favourite is using the -stdio option

Either:

sas -stdio

Then start typing. Or ...

echo "proc options; run;" | sas -stdio
Rog
  • 4,075
  • 2
  • 24
  • 35
5

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.

Triad sou.
  • 2,969
  • 3
  • 23
  • 27
3
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;'
Triad sou.
  • 2,969
  • 3
  • 23
  • 27
0

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
  • 18,877
  • 17
  • 76
  • 99
0

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