When you submit code or a catalog entry from the Enhanced Editor, the filename or catalog entry name and their respective folders are placed in these environment variables:
SAS_EXECFILEPATH
contains the full path of the submitted program or catalog entry. The full path includes the folder and the filename.
SAS_EXECFILENAME
contains only the name of the submitted program or the catalog entry name.
You can then extract the filename and full path for use in your SAS programs.
After the following DATA step runs and the data is sorted, the PRINT procedure includes the filename in the title and the full path in the footnote of the procedure output. The results are shown below as a Screen Shot
input variety $ flavor texture looks; |
total=flavor+texture+looks; |
The resulting output displays the filename in the title and the full path in the footnote:
Using an Environment Variable to Place a Filename in DATA Step Output
These environment variables are set only when code is submitted using the Enhanced Editor in the Windows environment. They are not set when you submit SCL code or when you submit code in a batch session.
However, when SAS is running in batch mode, you can obtain the full path (which includes the filename) by submitting %sysfunc(getoption(SYSIN)) . The following macro can be used to obtain the full path in both a batch session and an interactive session by using the Enhanced Editor:
%let execpath=%sysfunc(GetOption(SYSIN)); |
%then %let execpath=%sysget(SAS_EXECFILEPATH); |
You can also use the following %PUT macro statements to display the filename and full path in the SAS log: |
%put Submitted file path is %sysget(SAS_EXECFILEPATH).; |
%put Submitted file name is %sysget(SAS_EXECFILENAME).; |
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.