SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Jim_Hayes
Calcite | Level 5

Greetings.

I want to call a SAS program directly from a perl script.

I have been able to call a .bat file which successfully runs the job, but would prefer to be able to execute the job directly from perl.

--Jim

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Not familiar with Perl, however if you can call a .bat file, then presumably you can access the command line via the same method.  You would need to execute via command line something along the lines of

...\sas 9.2\sas.exe your_sas_script.sas

The SAS.EXE is the main executable which will open and compile the sas program.

Jim_Hayes
Calcite | Level 5

That was my first attempt.  but it failed. 

--Jim

SASKiwi
PROC Star

I suggest you test your SAS command first from a Windows command line. Once you have it working you can paste it into your Perl program. Also check out the SAS command documentation and try the -sysin option as well: ...\sas.exe -sysin mysasprog,sas.

FriedEgg
SAS Employee

With Windows, you can use the integration technologies client com interfaces to interact with a local sas installation (even if you do not license integration technologies).  I may not be a necessary level of integration for you, especially given the presumption that you are a perl novice.  To call SAS directly from perl use the system command:

system - perldoc.perl.org

@args = ("C:/path/to/sas.exe", "sysin C:/path/to/code.sas");

system(@args) == 0 or die "oops\n"

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1578 views
  • 0 likes
  • 4 in conversation