LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (August 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 22 Aug 2007 12:18:39 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: Comparing character values in MACRO
Comments: To: k_nallapeta@hotmail.com
Comments: cc: jerryang@CISCO.COM
In-Reply-To:  <BAY104-F3431F724DFCE41D9E2605495D50@phx.gbl>
Content-Type: text/plain; format=flowed

Okay Im going to stick my nose in on this thread......

The Macro language doesnt really need nor does it use qoutes like the data step or a procedure does. This goes to the fundamental difference between the data step language and the macro language. In the data step language words have meaning and as such it is the programmers responsability to delineate between what they want SAS to interprete (ie have meaning) and that which should just be considered text (ie, surround with qoutes). In the macro language everything is just text and it is the programmers responsability to deleneate between what words SAS should interprete with a special meaning (ie. prefixing words with % and & ) .

That said all you need to do is drop the qoutes all together unless the underlying value has qoutes in it.

%if ( &cal_day = THURSDAY ) %then %do; %put CONDITION MATCH! ; %end; %else %do; %put CONDITION DID NOT MATCH! TRY AGAIN ; %end;

Toby Dunn

Two wrongs are only the beginning.

Success always occurs in private and failure in full view.

Experience is something you don't get until just after you need it.

From: Kiran Nallapeta <k_nallapeta@HOTMAIL.COM> Reply-To: Kiran Nallapeta <k_nallapeta@HOTMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Comparing character values in MACRO Date: Wed, 22 Aug 2007 16:03:09 +0530

Hi,

Just add quotes, and your code will work...

%if ("&cal_day" ="THURSDAY") %then %do; %put "CONDITION MATCH! "; %end; %else %do; %put "CONDITION DID NOT MATCH! TRY AGAIN"; %end;

Cheers! Kiran

>From: SASJer <jerryang@CISCO.COM> >Reply-To: SASJer <jerryang@CISCO.COM> >To: SAS-L@LISTSERV.UGA.EDU >Subject: Comparing character values in MACRO >Date: Wed, 22 Aug 2007 01:10:50 -0400 > >I am having some trouble comparing character values in macro form. > >So i have the follwing statement: >%if (&cal_day ="THURSDAY") %then %do; >%put "CONDITION MATCH! "; >%end; >%else %do; >%put "CONDITION DID NOT MATCH! TRY AGAIN"; >%end; > > >When &cal_day is "THURSDAY" the out statement still shows the condition not >matching. Basically it will always go to the out statement. the cal_Day is >taking from a dataset that is char(40). Could it be the length difference? > >I tried to use %trim() on it cuase i thought it could be some whitespace >issue, but that didn't work. > >Anyone have ideas?

_________________________________________________________________ Voice your questions and our experts will answer them http://content.msn.co.in/Lifestyle/AskExpert/Default01.htm

_________________________________________________________________ Now you can see trouble…before he arrives http://newlivehotmail.com/?ocid=TXT_TAGHM_migration_HM_viral_protection_0507


Back to: Top of message | Previous page | Main SAS-L page