BookmarkSubscribeRSS Feed
acordes
Rhodochrosite | Level 12

I cannot find out how to auto-reference to its own path when I run a save sas program or a saved flow. 

 

In this case executing on of the flows I want to assign or use a macro variable with /Public/AC_ODAP/flows.

None of the solutions of my research, i.e.  &_SASPROGRAMFILE, work for me. 

 

I cannot even find the value /Public/AC_ODAP/flows on the log of the successfully executed flow. 

 

PIC.png

4 REPLIES 4
grace_sas
SAS Employee

Hi @acordes , 

 

In Viya 4, &_SASPROGRAMFILE is populated when running a program, but not when running a flow. 

 

In the SAS Studio React rewrite coming up,  

  • If the flow is saved on SAS Server - _SASPROGRAMFILE=/tmp/testProgram.flw
  • If the flow is saved on SAS Content - _SASPROGRAMFILE=sascontent:/dataFlows/dataFlows/ca756d2b-ea42-410b-9532-b601417d1604

 

I had offered to a customer a method of using autocall macros and the system option  MAUTOCLOCINDES to give the path and program name when run in a flow.

 

MAUTOLOCINDES  Specifies whether the macro processor prepends the full pathname of the autocall source file to the description field of the catalog entry of compiled autocall macro definition in the Work.SASMacr or Work.SASMacn catalog.

 

The steps you could follow are:

  1. Create a program test.sas with this code:
    %macro test;
    %put Running test macro;
     
    proc catalog ;
    contents catalog=work.sasmacr out=work.cat; 
    run;
     
    proc sql noprint;
    select desc into :path
    from work.cat
    where upcase(name) = 'TEST';
    quit;
     
    %put &=path;
    %mend test;
    
  2. Add that macro/program to a autocall library.  To do that, you create a directory and place the file test.sas in it.
  3. At some point before  you run the flow – probably in the autoexec – you define the autocall macro and set the option.
  4. Create a node in a flow that calls the macro %test.

So specifically this is what I did.

1. Created a directory under my home called autocall_files.  Placed the test.sas file in that directory.

 

 

grace_sas_3-1738778045168.png

 

 

2.  Modified my autoexec (this can be done at different levels such as compute context) to define the location of the autocall library:

 

grace_sas_4-1738778045170.png

3. Created a flow that contains a program node that runs the macro %test.

 

grace_sas_5-1738778089704.png

 

 

4. Ran the flow and saw the macro variable &path contain the path and name of the program. 

 

grace_sas_6-1738778089708.png

 

 

Let me know if you have questions or if you try that method and it works for you.

 

Regards,

Grace 

 

acordes
Rhodochrosite | Level 12

Hi Grace,

 

there are several issues when trying to apply your proposal.

I cannot get the macro to autoexecute at session start. 

Therefore the flow runs into an error complaining that %test macro is not defined.

When I run the macro set-up manually, then the flow (saved in my My Folder) executes but the log leaves the path blank.

 

145  %test;
Running test macro
NOTE: The data set WORK.CAT has 32 observations and 8 variables.
NOTE: PROCEDURE CATALOG used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
PATH=
146

 

It's because the work.cat has no info for the DESC variable. I do find the test macro, but its DESC is empty as for all 32 lines. 

 

grace_sas
SAS Employee

@acordes , hmm....I just had a colleague go through the process and it worked fine. 

 

Did you modify your personal autoexec (by going to Options>Autoexec) and add the correct lines?  Can you check that those lines were saved to the autoexec?

snip1.png

 

It sounds like you might have called %test before the system option MAUTOLOCINDES  was set.  If that was the case, the definition for the macro test would have been added to work.sasmacr without the DESC field.  If you then set the system option and reran %test, the DESC will still be blank because the macro has already been added to the catalog. 

 

The order is important in that  MAUTOLOCINDES  needs to be set before the first call to %test in order for the DESC to be added to the catalog and the dataset.  

 

I would be happy to help you further through a technical support case if you need more assistance. 

https://support.sas.com/en/technical-support.html

 

Regards,

Grace 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 4 replies
  • 1741 views
  • 1 like
  • 2 in conversation