BookmarkSubscribeRSS Feed
Ron_MacroMaven
Lapis Lazuli | Level 10

reddyr1 wrote:

\begin{question}

%macro eye (eye,dat, id);

data adae ;

  set adamdata.adae;

  where &cond1;

    run;

%mend eye;

The where condition(in red color) needs to be modified for each table.

Eg: where ethnicity="Hispanic"

\end{question}

your problem is that you want to pass a string with an equals sign in it

as a parameter.

change from special character (=) to mnemonic (eq)

%macro eye (eye=,dat=, id=,cond1=);

%put &=cond1;

* ... where &cond1;

run;

%mend;

%eye(eye=,dat=,id=

,cond1=ethnicity eq 'Hispanic');

3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10

Look at using the %quote(....) macro function to enclose your data-passed WHERE logic.

> suggested SAS.COM reference search argument:  pass quotes macro invocation site:sas.com

Scott Barry

SBBWorks, Inc.

Reeza
Super User

Yes, I asked a similar question a few weeks ago and it seems to work fine. I didn't have to mask anything.

https://listserv.uga.edu/cgi-bin/wa?A2=ind1506a&L=SAS-L&P=91498

Tom
Super User Tom
Super User

There is no need to change the parameter DEFINITIONS from positional to named, you can call position parameters by name.

%eye(eye=varx='blue')

You can also add () which should not impact the where clause.

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
  • 3 replies
  • 795 views
  • 1 like
  • 4 in conversation