Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to run SAS program in UNIX Bash shell script?

Posted on 2012-03-20
4
Medium Priority
?
3,952 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Progress
Suggested Courses

618 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