Hello,
I use this program to obtain path and file name:
%let execpath=" ";
%macro setexecpath;
%let execpath=%sysfunc(GetOption(SYSIN));
%if %length(&execpath)=0
%then %let execpath=%sysget(SAS_EXECFILEPATH);
%mend setexecpath;
%setexecpath;
%put &execpath;
The result is something like this:
XX$XX:[XX.myfolder.program]program_name.SAS
I just want to use a portion of the result like 'program_name' instead of typing the program name as a rtf file name each time.
I tried this, thinking that I would have a long file name:
ods rtf file="%sysfunc(getoption(SYSIN)).rtf";
But, I got an error message:
ERROR: Invalid open mod
I do not need the full information to start with, but could anybody tell me what I should write after 'ods rtf file=' to get just a program_name?
Thank you,
Yoko
I really don't think that is your best option, the code will not work if run in batch for instance. However you could change your code to make it work for now:
data _null_; tmp="%sysfunc(GetOption(SYSIN))"; call symput('fname',scan(tmp,2,"]")); run; ods rtf file="&fname."; ...
What I am doing here is putting the macro data into a datastep and using nice simple base SAS commands to process the data (for that is what Base SAS is for) to process the string, pull out the bit I want and then send back to macro.
I really don't think that is your best option, the code will not work if run in batch for instance. However you could change your code to make it work for now:
data _null_; tmp="%sysfunc(GetOption(SYSIN))"; call symput('fname',scan(tmp,2,"]")); run; ods rtf file="&fname."; ...
What I am doing here is putting the macro data into a datastep and using nice simple base SAS commands to process the data (for that is what Base SAS is for) to process the string, pull out the bit I want and then send back to macro.
Thank you, it worked!
Yoko
Are you working on a windows system, using the Enhanced editor (which implies running in Display Manager)?
If not the SAS_EXECFILEPATH isn't available.
If you are the value isn't set until after you save the program file.
And to get just the path if the above conditions are met (and assuming you don't put periods in the middle of your paths, of so...)
%let execpath= %scan(%sysget(SAS_EXECFILEPATH),1,.);
%put &execpath; (if you want to see the resolved version)
ods rtf file="&execpath..rtf"; should then work.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.