BookmarkSubscribeRSS Feed
WorkingMan
Calcite | Level 5

I first developed a Macro script in SAS EG, which will update a set of records into a SAS BASE Table.

 

I then make this a Macro Script dynamic that will take in parameter based on every session. I stored this Macro script as .sas file in the physical path in the server.

(Assume it is /sasapp/macro).

The screenshot for this script(I cant copy the script out because the server doesnt allow us to copy paste😞

EdS2KcK

juex43G

 

It works perfectly fine when i run the script in SAS EG.

 

 

I configured SASAUTOS in sasv9.cfg to include SAS Auto Macro in this directory. However, even after configuring and restarting objectspawner, it is not taking effect for this new directory. My plan is that I set to trigger this macro.sas everytime i run a job in SAS DI Studio.

 

To further troubleshoot, I re-trigger/re-run in the original sas macro script using SAS EG, It works. However, when i try the command below, It doesn't work. Now, I am not sure what is wrong.

 

filename ptmacro '/sasapp/macro/jobctrl.sas';
%include ptmacro;

%startjob(1, test, started);

 

 

The error that I am getting:

rXmg7Nm

 

 

 

My question is, why running %startjob in the original full macro script works in SAS EG, but if i use %include in a new SAS Session and try to trigger with %startjob (without full macro script this time), it gives error.

9 REPLIES 9
WorkingMan
Calcite | Level 5
Hi Kurt, did u mean
%macro startjob( );
in the .sas file?

I have that...the .sas script has the same exact script as my EG body
Kurt_Bremser
Super User

Wait...

did you put this into your AUTOCALL folder? If you want to use the SAS AUTOCALL facility, the name of the macro must be identical to the name of the SAS file. So if your macro is called startjob, the file must be saved as startjob.sas in the AUTOCALL facility.

 

Otherwise, your code must work:

I created this program:

%macro startjob(JOBID,ETLS_JOBNAME,STATUS);
%put &=JOBID;
%PUT &=ETLS_JOBNAME;
%put &=STATUS;
%mend;

and saved in as jobctrl.sas in my /folders/myfolders in SAS University Edition.

Then I ran this:

filename ptmacro '/folders/myfolders/jobctrl.sas';
%include ptmacro;

%startjob(1,test,started)

and got this log:

 73         filename ptmacro '/folders/myfolders/jobctrl.sas';
 74         %include ptmacro;
 80         
 81         %startjob(1,test,started)
 JOBID=1
 ETLS_JOBNAME=test
 STATUS=started
 82         
Patrick
Opal | Level 21

If extending SASAUTOS either in a .cfg or an autoexec make sure you add this to the one with usermods in the name. You are not supposed to change the other ones and applying a SAS patch or upgrade will potentially overwrite them.

 

The filename of your autocall macro must be all lowercase and it must be the name of your macro. So if your macro is called %startjob() then the filename must be startjob.sas

 

In the sample code you've posted: The included file is jobctrl.sas - why would this compile macro %startjob()?

 

 

WorkingMan
Calcite | Level 5

Thanks @Patrick and @Kurt_Bremser . I followed your advice by renaming my file name to startjob.sas

Miraculously, it is able to read the folder that stores the macro script.

 

However, I am now hitting a new error :
dbou9tl

 

This is the only error in DI job....What is wrong with this? I dont see anything wrong...just weird to me.

Kurt_Bremser
Super User

If you extended your AUTOCALL configuration for the Workspace Server, you must also include this change for the Data Step Batch Server. Or (still better) make the change in the parent directory of both (usually SASApp).

Patrick
Opal | Level 21

I normally debug such DIS code using EG - just copy the code from DIS from top until this line of code. Set options mprint mlogic and then execute and fix the code.

There is either something wrong in your macro code or may-be you just need an %unquote(&jobid). 

ballardw
Super User

@WorkingMan wrote:

Thanks @Patrick and @Kurt_Bremser . I followed your advice by renaming my file name to startjob.sas

Miraculously, it is able to read the folder that stores the macro script.

 

However, I am now hitting a new error :
dbou9tl

 

This is the only error in DI job....What is wrong with this? I dont see anything wrong...just weird to me.


What is the value of the macro variable &Jobid at this time?

Debugging macros means setting the system options MPRINT and often SYMBOLGEN to see the code generated/submitted. And you may want SOURCE2 to show that the %include file is used properly.

Patrick
Opal | Level 21

@ballardw 

&jobid is a SAS Data Integration Studio generated and populated macro variable. It's always at the very beginning of the generated SAS code and contains the SAS Metadata ID to the DIS job metadata definition used to generate the SAS code from.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 9 replies
  • 732 views
  • 0 likes
  • 4 in conversation