Desktop productivity for business analysts and programmers

how to exeute one sas prog in another sas prog

Reply
N/A
Posts: 0

how to exeute one sas prog in another sas prog

i am working in BASE SAS 9.1..i have created one SAS programed Named ABC and now in coding of ABC.sas i want to execute another SAS prog named XYZ .SAS and i also want to check that XYZ has executed without any error successfully or not. i have to code all this in ABC.SAS prog.

what i have tried?
in ABC.SAS to execute XYZ.sas i have used the concept of rsubmit and not successed
Respected Advisor
Posts: 3,840

Re: how to exeute one sas prog in another sas prog

Look up what %include does - and just check return codes from time to time.

If you want to execute a program within a data step then you might want to learn about 'call execute'

You can always wrap a SAS Base program into a %macro ... %mend and then call the macro later on in your program (just link the objects in EG and have the code with %macro...%mend executed before you call the macros.

HTH
Patrick Message was edited by: Patrick
N/A
Posts: 0

Re: how to exeute one sas prog in another sas prog

i have tried call execute and %include.
i am trying to explain you my task.
i have one program ABC.SAS. In which i have to run many sas program like A1,A2,A3....A10.SAS . name all these sas program are in one sas data set. In the coding of ABC.SAS , i have to execute two and more jobs parallel by using rsubmit concept on server . And i also have to get the execution status like "executed without any error" for each this job.

i used rsubmit concept but it does not take the proper name of sas program submitted to it. whenever i submit the name of any sas program to server from client then it execute the previously submitted sas program e.g. first i submit A1.sas and second execution time i submit A2.sas but server will execute A1.sas.


please help me...thanks
Esteemed Advisor
Posts: 5,199

Re: how to exeute one sas prog in another sas prog

I think it's possible to do what your are after. Maybe it's some error in your program logic. To help you with that we need to see your program and detailed log (using options SOURCE2 and MPRINT MLOGIC SYMBOLGEN if you are using some macro functionality).

But when you are describing your application, it seems that are trying to accomplish the same functionality that are packaged into 3rd party scheduling software. Maybe you could look for that kind of solution for your task.

/Linus
Data never sleeps
N/A
Posts: 0

Re: how to exeute one sas prog in another sas prog

Hi actually i am passing name of the sas program on server using macro variable .but this macro variable is processed at compile time. i want it should be resolved at run time . that's why proper information is not reached at server. every time when i start execution of main sas program then server get the previous value of macro variable .i am sending you code if u can halp me

data _null_;
set
call symputx('jname','job_name');
signon first1;
CALL EXECUTE('%syslput rex_path=&EX_PATH;');
CALL EXECUTE('%syslput rjname=&JNAME;');
rsubmit first1 sysrputsync=yes notify=no wait=yes log="D:\ARVIND\AUTOMATE_TESTING\log.log";
LIBNAME AmdExStg "D:\ARVIND\AUTOMATE_TESTING\EXTRACTS"; /****THIS LIBRARY CONTAIN THE EXTRACTED TABLES**********/
%include "&REX_PATH\&RJNAME..sas";
%sysrput rt_rc = &trans_rc;
%sysrput rj_rc = &job_rc;
endrsubmit;

WAITFOR first1;
call execute('%PUT &rt_rc;');
call execute('%PUT &rj_rc;');
run;

in the above code trans_rc and job_rc ..return code which i want on client after execute XYZ.sas program on server. i got the XYZ.SAS file name from other SAS data set at run time and assign this file name to macro jname.

here JNAME is macro varible which get value at run time. actually my problem is here this variable is processed at compile time. but it should get value at run time . so that its updated value can be submitted to server.


conclusion : in sas wothout using Macro variable and Macro function ...programming possible ot not?
actually we know that Macro always processed at compile time ...this is a big problem....whereas i want it should be processed at run time....please help me....thanks
Esteemed Advisor
Posts: 5,199

Re: how to exeute one sas prog in another sas prog

There are several problems with this code. One major problem is that you are mixing data step, global statements, call execute, macro statements in an unorganized way. The result is that parts of your code will not execute in the intended order.

If you want to stick to your basic idea, try to move all of your non data step local statements to a macro, and using call execute with needed parameters.

Even if you get this to work, I think like Cynthia that using MP CONNECT would be a neater solution.

/Linus
Data never sleeps
Respected Advisor
Posts: 3,840

Re: how to exeute one sas prog in another sas prog

Hi

It's possible what you try to do - and I've seen it working as well.
Do you know this paper? http://www2.sas.com/proceedings/sugi29/124-29.pdf

I agree with Cynthia and Linus that a 3rd party job scheduler would be a better solution. But I also understand that there might be reasons why you can't do it (different department too slow reacting on change requests, no money,....).

We're talking about solutions here. But what is the problem? What do you really want to achieve (big picture)? And what's your environment? What's the OS of the server? (i.e. i've seen a neat 'scheduler' written in SAS together with some JCL for z/OS). Which SAS modules are available (i.e. MP Connect?).
Do you just need to batch a bunch of sas programs and collect the return codes - or do you also want to implement dependencies between the jobs; and what kind of dependencies?

I think before dealing with some coding issues in detail it would be important to get the architecture right. Ask these questions here. I'm sure you'll get some valuable ideas.

HTH
Patrick
N/A
Posts: 0

Re: how to exeute one sas prog in another sas prog

Hi..

i have windows xp sp2 as OS and i am working in base SAS 9.1. i have lot of SAS jobs developed by SAS DI STUDIO .
Now what i have to do...

i am writing a SAS program which will execute all these SAS DI jobs one by one and also store the result of execution of each job.

from performance point of view , i also have to execute all these jobs parallaly in my SAS program.
name of all these SAS job are stored in SASdataset file.

To complete this task what issues i am facing....
1. Macro variable always process at compile time but i want to it should be processed at runtime..becoz i needs its value at run time....at compile time these variable are having null value(default value) .
2. in one data step i can't call a macro program having data step.
3. at run time how can i call to macro program and it should be executed at run time.


actually i want to do SAS programming without using concept of macro .
it is possible or not ?

and how can i write small module function like sub program in "c" lang .
and how to run these module and integrate in main program



please guide thanks
Esteemed Advisor
Posts: 5,199

Re: how to exeute one sas prog in another sas prog

If your choice is to solve this via programming, I think that you already got enough tips to get the job done. If your site is using DI Studio, maybe a part of your logic can be addressed within DIS, check on-line doc and Forum papers for inspiration.

/Linus
Data never sleeps
SAS Super FREQ
Posts: 8,721

Re: how to exeute one sas prog in another sas prog

Hi:
One last thought. If you are using SAS DI Studio to create the jobs, then is it possible that you want/need to use the Platform LSF Scheduler??

Here are some references:
http://support.sas.com/rnd/scalability/platform/lsf6.2_get_started.pdf
http://support.sas.com/rnd/scalability/platform/lsf6.2_ref.pdf

And in the getting started primer, it says that:
There are three basic ways to integrate applications with LSF:
-- Wrapper shell scripts
-- Wrapper binary executables
-- Modifying existing application source code and interfaces


Just a thought. You might check with Tech Support for help with DI Studio jobs and/or the Platform LSF scheduler.

cynthia
Respected Advisor
Posts: 3,840

Re: how to exeute one sas prog in another sas prog

A real scheduler would be best, but...

Do you know this paper? http://www2.sas.com/proceedings/sugi27/p105-27.pdf
I think this comes close to what you want. The 'only' open question is how to catch the error-return codes. I found this paper which gives some examples how to do this - but you might find more accurate ones for your requirements with a bit more searching. http://home.att.net/~gobruen/progs/dos_batch/dos_batch.html

May be the Windows Task Scheduler is an option for you: http://support.sas.com/techsup/technote/ts648/ts648.pdf
I believe the task scheduler writes also a log with success/error information.

HTH
Patrick
SAS Super FREQ
Posts: 8,721

Re: how to exeute one sas prog in another sas prog

Hi:
Depending on how you're trying to run your jobs "in parallel", it's possible that you may have issues capturing all the return codes. You may be using RSUBMIT, when you should be using a job scheduler, as Linus suggested, or looking at MPCONNECT to perform parallel processing. Given the magnitude of the number of programs that are involved, I recommend that you contact SAS Tech Support.

cynthia
Ask a Question
Discussion stats
  • 11 replies
  • 155 views
  • 0 likes
  • 4 in conversation