BookmarkSubscribeRSS Feed
mick_g
Calcite | Level 5
Is there a was to execute a sas program from another sas program.

example:
retreivedata.sas creates a table from various sources.

myfile = sas_code\retreivedata.sas

data result;
set myfile;

if cat in ('specialty', 'lines') then cat = 'other';
run;
5 REPLIES 5
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Mick_g,

I did not get your point. If your "retreivedata.sas creates a table" then you simply use this name in the following datastep:
[pre]
data result;
set TableName;
if cat in ('specialty', 'lines') then cat = 'other';
run;
[/pre]
Sincerely,
SPR
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
With SAS system, you have some options like using a SAS view to generate a file and then reference the file in a subsequent DATA step, for example.

Also, if you use the SET statement and supply no specific input, SAS will default to the prior SAS member/file created in the same SAS session.

Also, if you wish to specify a SAS file to create and then in a subsequent input using a SET, then consider using a SAS MACRO variable to list the "passed" file name information, where it would be defined with a %LET statement, referenced on a DATA statement using the associated macro variable syntax, and then again later referenced, as needed, again with the macro variable syntax.

Otherwise, it's not really clear exactly what you are trying to accomplish and how to recommend an approach, without more specific detailed information.

Scott Barry
SBBWorks, Inc.
Peter_C
Rhodochrosite | Level 12
Interesting number of alternative interpretations of this question!
To add to the variety, I had assumed the names of the programs to be executed were in a variable of a metadata table. Then
CALL EXECUTE( '%include ' !! Quote( Cats( path, ProgName )) !! " ;" );
might do what is needed.

Peter
mick_g
Calcite | Level 5
I actually work the problem out a different way. I have three different programs that rely on the output of the the previous program.
so what I was trying to do is have the first programs executed the code from another programs to create a table in current program then send the results to another program for execution

here is how i fixed; in the first program i had an include statement to get code from another program in the second program I have an include first program in the third program i included code again from another program and include second program and I am now working witht the data.

I think there is an easier way but this works for now so thanks for the help
ballardw
Super User
If it is code used frequently it might be worth making it a macro and placing it in an AUTOCALL library.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1079 views
  • 0 likes
  • 5 in conversation