BookmarkSubscribeRSS Feed
trekvana
Calcite | Level 5
Hello all,

so I am working on this program:

%macro sc(i,resdata);
proc iml;
start delcol(x,i);
return(x[,setdif(1:ncol(x),i)]);
finish;

use test&i;
read all into x;
x=delcol(x,{1,2}); print x;

use &resdata;
read all var {Resid} into y where(id=(&i+1)&Resid^=.); print y;

sc=x*y; print sc;
quit;
%mend;

I am getting this error: WARNING: Apparent symbolic reference RESID not resolved.

I believe its from the part in the code I bolded. I think the macro thinks that resid is an input variable (like i and resdata) but it is really part of the where condition. Is there anyway I can tell the macro that &Resid is not part of the inputs?
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
It appears you are attempting to use the ampersand character as an operator "AND" condition. Separate the "&" from the SAS variable "Resid" so that SAS does not interpret the string as a macro variable.

Scott Barry
SBBWorks, Inc.
PatrickG
SAS Employee
Or try quoting the &...

where(id=(&i+1)%nrquote(&)Resid^=.); print y; sc=x*y; print sc; quit;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 663 views
  • 0 likes
  • 3 in conversation