| Date: | Wed, 12 Jan 2011 15:17:29 -0500 |
| Reply-To: | "Bian, Haikuo" <HBian@FLQIO.SDPS.ORG> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Bian, Haikuo" <HBian@FLQIO.SDPS.ORG> |
| Subject: | Re: Easy macro comparison |
|
| In-Reply-To: | <69698.27723.qm@web120518.mail.ne1.yahoo.com> |
| Content-Type: | text/plain; charset="iso-8859-1" |
Oh, if you are interested, there are numerous function available at your service: find(), findw(), or index etc.
For example,
If (find("&tablist.", "&tab." )) then do;
HTH,
Haikuo
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of William Krause
Sent: Wednesday, January 12, 2011 3:03 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Easy macro comparison
Thanks, That worked.
Bill K.
--- On Wed, 1/12/11, Jack Clark <jclark@hilltop.umbc.edu> wrote:
From: Jack Clark <jclark@hilltop.umbc.edu>
Subject: RE: Easy macro comparison
To: "William Krause" <wkrause2003@YAHOO.COM>, SAS-L@LISTSERV.UGA.EDU
Date: Wednesday, January 12, 2011, 1:57 PM
Bill,
You would have to put quotes around your reference to &tab.
if "&tab." in (&tablist.) then do;
Without the quotes, &tab resolves to mytable, which SAS will view as the
name of a data step variable (instead of a character constant).
Jack
Jack Clark
Senior Programmer
phone: 410-455-6256
fax: 410-455-6850
jclark@hilltop.umbc.edu
University of Maryland, Baltimore County
Sondheim Hall, 3rd Floor
1000 Hilltop Circle
Baltimore, MD 21250
Please consider the environment before printing this e-mail and/or any attachments.
Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee(s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
William Krause
Sent: Wednesday, January 12, 2011 2:51 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Easy macro comparison
I have two macro variables:
&tab which contains a name of a table as mytable
&tablist which contains a list of table names as
"hertable","histable","mytable","theirtable"
In a data step, how would I compare &tab to the &tablist
in order to find mytable.
data test ;
set intest ;
if &tab in (&tablist) then do ;
if id = '1' then delete ;
end ;
run ;
Nothing happens.
Id of 1 exists in intest.
mytable is in the list of table in &tablist.
I would expect that the row with id of 1 would be delete therefore
my dataset would have 1 less obs.
Suggestions.
Thanks.
Bill K.
-----------------------------------------
Email messages cannot be guaranteed to be secure or error-free as
transmitted information can be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The
Centers for Medicare & Medicaid Services therefore does not accept
liability for any error or omissions in the contents of this
message, which arise as a result of email transmission.
CONFIDENTIALITY NOTICE: This communication, including any
attachments, may contain confidential information and is intended
only for the individual or entity to which it is addressed. Any
review, dissemination, or copying of this communication by anyone
other than the intended recipient is strictly prohibited. If you
are not the intended recipient, please contact the sender by reply
email and delete and destroy all copies of the original message.
|