1
votes

How can I write and run SAS code from linux command line (eg, the terminal, from which all other programs can be executed)?

Eg, use a text editor to create a file like 'file.sas' then run in the command line

'sas file.sas'

Ie, can I run without using the sas command line and user interface

For example, in python you can write a .py script in a text editor and execute using python file.py

3
sas program_name.sas is the correct method to call a program from the command line. What is the issue you're experiencing? Or why do you think it's not working.Reeza
SAS is not open source, but has a body of knowledge that goes back to the 70's. You can find many resources on lexjansen.com or communities.sas.com but not many users use SO for SAS questions.Reeza

3 Answers

3
votes

As long as you can locate the SAS Foundation installation folder you can execute a sas session from the terminal.

See sample command below: opening a sas session and specifying the file to execute and where to save the log file:

/sas/940/SASFoundation/9.4/sas /projects/program1.sas -log "/projects/program1.log" 

SAS Command line documentation here

0
votes

On your SAS command line you can -set an environment variable that is used by your program.

sas ... -set pdf_file op.pdf -sysin myProgram.sas

myProgram.sas
-------------
...
filename pdf_out = "%sysget(pdf_file)";
ods pdf file=pdf_out ...;
proc ...
-1
votes

Yes, you can run a sas script from terminal, without the sas user interface. Also you can put this into the sas script

ods pdf file = 'op.pdf';

So when calling from terminal, don't need to direct output via >>