Solved

How to run SAS program in UNIX Bash shell script?

Posted on 2012-03-20
4
3,282 Views
Last Modified: 2012-03-21
I am trying to run .SAS program (test1.SAS) from Unix Bash shell script file. Please let me know what I am doing wrong in my Bash shell script or in my  .SAS program code.

Note: SAS dataset "dataset1.sas7bdat" does exist in the "testing" directory in Unix.

Unix Bash shell script

#script - tmp1.sh
#!/bin/bash
mydir=/2011/march/tuesday/testing
export mydir
sas=/products/SAS/SASFoundation/9.2/sas
$sas test1
exit

Open in new window



SAS

#filename test1.sas
libname lib "$mydir";
data lib.dataset2;
   set lib.dataset1;
   if _N_ < 10 then output;
run;

Open in new window


Are there any other ways to run SAS programs (with SAS datasets) from Unix bash shell script?
0
Comment
Question by:labradorchik
  • 2
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 500 total points
ID: 37745647
you'll need to use the sysin parameter:
-sysin [filename.sas]

i can't remember if you can trigger a sas session by just sas, or if sas.sh is needed, but it should look like:
> sas -sysin test1.sas

or

> sas -sysin [full path]\test1.sas

there are other options you can include like -autoexec, -log etc
0
 

Author Comment

by:labradorchik
ID: 37747592
Thank you very much, lowaloysius!!

I will definitely try your way trigger SAS as well, but is it OK to reference  "mydir" logical as I did in the test1.SAS?
libname lib "$mydir";

Open in new window


Also, what if I want to reference a directory with a file (.SAS, .DAT, or .sas7bdat), would it logically work?
 
Thank you!
0
 
LVL 14

Expert Comment

by:Aloysius Low
ID: 37747859
no it won't work... that is a UNIX variable which you are trying to use in a SAS session...

like i mentioned in my other answer, that's AFAIK... i'll be glad if a fellow expert proves me wrong on this...
0
 

Author Closing Comment

by:labradorchik
ID: 37747940
Thank you!!
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ejb wildfly example 2 28
subtr returning incorrect value 8 33
Create .bat File 16 37
How to structure query with count aggregate 4 19
A short article about problems I had with the new location API and permissions in Marshmallow
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question