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.
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 12 replies
  • 1981 views
  • 0 likes
  • 3 in conversation