BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
David_Billa
Rhodochrosite | Level 12

When I try to execute the code below, I'm getting error stating that ,

 

ERROR 180-322: Statement is not valid or it is used out of proper order.
WARNING: Apparent symbolic reference MAC_LIST not resolved.

 

Now I would like to execute the macro even when the macro MAC_LIST  is not resolved. I don't want to see the error and also I want program to continue processing.

 

data &_OUTPUT.(keep= FLT_ID RUN_ID);
	set &_INPUT.;
        &mac_list.;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

You could ensure that the macro variable always exists, i.e. by adding the following before your datastep.

%global mac_list;

 

View solution in original post

4 REPLIES 4
Patrick
Opal | Level 21

You could ensure that the macro variable always exists, i.e. by adding the following before your datastep.

%global mac_list;

 

David_Billa
Rhodochrosite | Level 12
Any other ways to solve the problem?
Patrick
Opal | Level 21

Not as simple as using a %global statement (or a %local statement within a macro definition).

 

If your code is within a SAS macro definition then you can also use %symexist as below:

/*%let mac_list= newvar=1;*/

%macro test();
  data sample;
    set sashelp.class;
    %if %symexist(mac_list) %then &mac_list; ;
  run;
%mend;
%test();

proc print data=sample;
run;

 

Amir
PROC Star

Hi @David_Billa thanks for supplying the code and the error message, as it helps coming up with a solution.

 

If any of @Patrick 's responses works for you then please accept it (not my post) as the solution.

 

Thanks & kind regards,

Amir.

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