BookmarkSubscribeRSS Feed
MG18
Lapis Lazuli | Level 10

Hi All,

I have created one SAS job with below mentioned user written code which is failing with error due to it is not assigning correct variable value.

%include '/sascon/Lev1/Applications/SASAntiMoneyLaundering/5.1/BUJO/custom/config/autoexec.sas';

%macro aml_dwjn_monthly;

%local dwjn_file;

%let dwjn_file=/sascon/Lev1/Applications/SASAntiMoneyLaundering/5.1/BUJO/watchlist/CSV_PFA_201808042200_D.csv;

%put &dwjn_file;

%include '/sascon/Lev1/Applications/SASAntiMoneyLaundering/5.1/BUJO/custom/source/aml_load_watch_list_dwjn_monthly.sas';

%aml_load_watch_list_dwjn_monthly (dwjn_file=&dwjn_file);

%mend aml_dwjn_monthly;

%aml_dwjn_monthly;

 

 

 User Written   Line 4,992: WARNING: The text expression &DWJN_FILE contains a recursive reference to the macro variable DWJN_FILE. The macro variable will be assigned the null value.

   

    Line 4,992: ERROR: Invalid physical name.    Line 4,992: ERROR: Error in the FILENAME statement.

 

Can some body help me why this macro variable is assigning to null value but it is  giving expected result in %PUT statement.

How i can resolve this error ?

 

 

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

The message means that somewhere, the code generates the equivalent of:

%let DWJN_FILE= ... &DWJN_FILE ... ;

which is a recursive reference.

 

AhmedAl_Attar
Ammonite | Level 13

Hi @MG18

 

You are using the following code lines (Partial extract)

%local dwjn_file;
%let dwjn_file=/sascon/Lev1/Applications/SASAntiMoneyLaundering/5.1/BUJO/watchlist/CSV_PFA_201808042200_D.csv;
%put &dwjn_file;

%include '/sascon/Lev1/Applications/SASAntiMoneyLaundering/5.1/BUJO/custom/source/aml_load_watch_list_dwjn_monthly.sas';
%aml_load_watch_list_dwjn_monthly (dwjn_file=&dwjn_file);

*

%aml_load_watch_list_dwjn_monthly (dwjn_file=&dwjn_file);  /* This is the offending line! */

I would suggest the following miner change, to clarify your code and avoid the error you are getting now

 

%include '/sascon/Lev1/Applications/SASAntiMoneyLaundering/5.1/BUJO/custom/config/autoexec.sas';
%macro aml_dwjn_monthly;
   %local l_dwjn_file;   /* Added 'l_' prefix to indicate local scope */
   %let l_dwjn_file=/sascon/Lev1/Applications/SASAntiMoneyLaundering/5.1/BUJO/watchlist/CSV_PFA_201808042200_D.csv;
   %put &l_dwjn_file;

   %include '/sascon/Lev1/Applications/SASAntiMoneyLaundering/5.1/BUJO/custom/source/aml_load_watch_list_dwjn_monthly.sas';
   %aml_load_watch_list_dwjn_monthly (dwjn_file=&l_dwjn_file);
%mend aml_dwjn_monthly;
%aml_dwjn_monthly;

Hope this helps,

Ahmed

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5 replies
  • 5418 views
  • 2 likes
  • 3 in conversation