BookmarkSubscribeRSS Feed
PratapDeo
Calcite | Level 5

Hi All,

I am stuck with a reqiuirment where I have to create one sas code from another sas code dynamically during run time in linux 

 

I need help urgently.

Many Thanks

12 REPLIES 12
Reeza
Super User

So what do you need help with?

That's an incredibly broad topic but you can definitely:

 


 


create one sas code from another sas code dynamically during run time in linux 

 

PratapDeo
Calcite | Level 5

thanks Reeza,

actually, when we read one file in sas code A and based on few conditions code A will create code B. so How the code from A will go to code B. As in the case of sas-mainframe where we dynamically create job from another job;there in the first job we give the code og 2nd job under "PUT AAAAA; " statement and once job1 is submitted it will create job2 with the code AAAA;

Reeza
Super User

You can dynamically create the code, place it in a text file in the work library and then use %include to call the program.

PratapDeo
Calcite | Level 5

ok....but few fields in the 2nd job has to be changed based on the few conditions in the 1st job and the input file read..so how this change of certain fields in the 2nd job will be reflected dynamically 

Quentin
Super User
It would REALLY help if you gave an example. There are lots of possibilities for dynamic code generation in SAS (the %include method Reeza mentioned, macro language, CALL EXECUTE, etc). If you can give an example of the code you have, and the code you want to generate, that would help. Would also help to explain the problem you are trying to solve. Code generation is a useful technique, but depending on the problem being solved, may not be necessary.
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
PratapDeo
Calcite | Level 5

ok..will try to elaborate my prob. I have one code A, from whcih I have to generate a code B. In code A, there is one field called Vendor_code. This code is reading one input file which has say 3 vendor codes. so based on few conditions code A will generate code B at the same time it will populate the value of vendor_code in the generated code i.e. code B. e.g. if there are 3 vendor codes then 3 set of codes will be generated from the 2st code A with the different values of vendor_code in code B

Reeza
Super User

Write a macro. Use call execute to call the macro that has the vendor codes.

 


@PratapDeo wrote:

ok..will try to elaborate my prob. I have one code A, from whcih I have to generate a code B. In code A, there is one field called Vendor_code. This code is reading one input file which has say 3 vendor codes. so based on few conditions code A will generate code B at the same time it will populate the value of vendor_code in the generated code i.e. code B. e.g. if there are 3 vendor codes then 3 set of codes will be generated from the 2st code A with the different values of vendor_code in code B


 

PratapDeo
Calcite | Level 5
Many thanks Reeza, will try your sugesstions.
PratapDeo
Calcite | Level 5

Hi,

Could you please help me to get the syntax/format to submit another job from first job.

Like in SAS program we use SUB 'file-name' ;

Reeza
Super User

%INCLUDE

PratapDeo
Calcite | Level 5
While using %INCLUDE file-name to run another program from the first program, I am getting the error message " File is in use" . Do I need to close the file.
Reeza
Super User

Your question is too broad. Yes you can do what you want is all we can tell you without further details. Mock up a test of what you need to do, which you should be doing anyways so you can test your process and post that information. 

 


@PratapDeo wrote:

ok....but few fields in the 2nd job has to be changed based on the few conditions in the 1st job and the input file read..so how this change of certain fields in the 2nd job will be reflected dynamically 


 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 12 replies
  • 1252 views
  • 0 likes
  • 3 in conversation