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

Happy New Year to you all.
I have the following in a macro containing proc report but it says - WARNING: Apparent symbolic reference BIGN1 not resolved. Same goes to BIGN2, BIGN3 and BIGN4. 

data _null_;  
	set bign03(where=(cond1=&sub1 and cond2='&sub2')); 
	call symput('bign' || strip(put(tx,8.)), trim(left(put(bign,8.))));
run;

proc report ...;
...;
...;

  define tx1 / display width=20 'A#   N=%trim(&bign1)';
  define tx2 / display width=20 'B#   N=%trim(&bign2)';
  define tx3 / display width=20 'B#   N=%trim(&bign3)';
  define tx4 / display width=20 '   Total#   N=%trim(&bign4)';
...;
run;

I tested by conditioning on cond1=1 and cond2='A' and running it outside of the macro and it runs without this warning or errors.
I don't understand why. Could you please advise what have I not done right here?
Thanking you in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Check your SAS log for the notes. In particular the notes from the DATA _NULL_ step that is creating the macro variables. It will most likely show that zero observations were read from the BIGN03 dataset.

That is because I suspect that you wanted the WHERE= dataset option to compare the value of the variable COND2 to the value of the macro variable SUB2.  Instead you tested if the variable COND2 literally match the string '&sub2'.  This is because macro code inside of single quotes is ignored. Use double quote characters instead.

data _null_;
  set bign03 ;
  where cond1=&sub1 and cond2="&sub2";
  call symputx(cats('bign',tx),bign);
run;

proc report ... ; 
  define tx1 / display width=20 "A# N=&bign1"; 
  define tx2 / display width=20 "B# N=&bign2"; 
  define tx3 / display width=20 "B# N=&bign3";
  define tx4 / display width=20 "Total# N=&bign4"; 
  ...
run;

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Check your SAS log for the notes. In particular the notes from the DATA _NULL_ step that is creating the macro variables. It will most likely show that zero observations were read from the BIGN03 dataset.

That is because I suspect that you wanted the WHERE= dataset option to compare the value of the variable COND2 to the value of the macro variable SUB2.  Instead you tested if the variable COND2 literally match the string '&sub2'.  This is because macro code inside of single quotes is ignored. Use double quote characters instead.

data _null_;
  set bign03 ;
  where cond1=&sub1 and cond2="&sub2";
  call symputx(cats('bign',tx),bign);
run;

proc report ... ; 
  define tx1 / display width=20 "A# N=&bign1"; 
  define tx2 / display width=20 "B# N=&bign2"; 
  define tx3 / display width=20 "B# N=&bign3";
  define tx4 / display width=20 "Total# N=&bign4"; 
  ...
run;

 

Miracle
Barite | Level 11

Thanks @Tom for your quick response.
It is now working after replacing the single quote to double quotes.
Thanks again.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 2 replies
  • 2342 views
  • 0 likes
  • 2 in conversation