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.
@BrunoMueller at the rescue 😉
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,
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:
%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;
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.
2. Modified my autoexec (this can be done at different levels such as compute context) to define the location of the autocall library:
3. Created a flow that contains a program node that runs the macro %test.
4. Ran the flow and saw the macro variable &path contain the path and name of the program.
Let me know if you have questions or if you try that method and it works for you.
Regards,
Grace
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.
@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?
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
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.
Ready to level-up your skills? Choose your own adventure.