LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2008, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 30 Oct 2008 17:18:06 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Subject:      Re: Test if a var is available inside data step?

On Thu, 30 Oct 2008 14:52:58 -0400, Ya Huang <ya.huang@AMYLIN.COM> wrote:

>Hi there, > >%macro cat(v1=,v2=,v3=); >&v3=trim(&v1)||trim(&v2); >%mend cat; > > >*first call is OK; >data xx; > set sashelp.class (obs=1); >%cat(v1=sex,v2=name,v3=sname); >run; > >proc print; >run; > >*second call failed, because name is not available; >data yy; > set sashelp.class (obs=1 drop=name); >%cat(v1=sex,v2=name,v3=sname); >run; > >proc print; >run; > >What I want is somehow add test in the macro, so that if v2 >is not available, then switch to > >&v3=trim(&v1)||trim(&v2); >to >&v3=trim(&v1); > >The message like "NOTE: Variable name is uninitialized" should >be avoided too. > >Thanks > >Ya

Try

&v3=trim(&v1)||trim( vvaluex("&v3") );


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