I am trying to get the batch mode value first but it is blank so then revert to using the _SASPROGRAMFILE macro var.
I wonder if there is a better way to handle this.
This happens when I submit the code using RSUBMIT
%macro pgmname() ;
%local retval ;
%let retval = %sysfunc( getoption( sysin ) ) ; /* batch mode */
%if %isblank( &retval. ) %then %let retval = &_SASPROGRAMFILE ; /*interactive mode */
/* next line removes single quotes produced in interactive mode */
%qsysfunc( compress( &retval., %str(%') ) )
%mend ;
Sysin gives you the name of a program that was used on the commandline of a SAS batch process. When SAS is started via CONNECT, there is no such program present, so sysin (and _sasprogramfile) will be empty or nonexistent.
Nothing is happening in what you have shown. That is only the definition of a macro. There is no indication that you have actually executed the macro or any description of running the macro. Also since there is no reference to RSUBMIT it is very hard to even guess what the macro is supposed to do in relation to RSUBMIT.
To show a result it may be necessary to set options mprint symbolgen; prior to the code. Then show the results with code and messages from the log for the submission involving the macro definition, execution and the code using rsubmit.
It may be better to paste the log results in a code box opened with the {I} icon.
Sysin gives you the name of a program that was used on the commandline of a SAS batch process. When SAS is started via CONNECT, there is no such program present, so sysin (and _sasprogramfile) will be empty or nonexistent.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.