Solved

How to run SAS program in UNIX Bash shell script?

Posted on 2012-03-20
4
3,568 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Six Sigma Control Plans

717 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