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 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 8 Oct 2009 08:22:55 -0500
Reply-To:     "Data _null_;" <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Data _null_;" <iebupdte@GMAIL.COM>
Subject:      Re: %sysfunc with CATS function
Comments: To: "ajs2004@bigfoot.com" <ajs2004@bigfoot.com>
In-Reply-To:  <3ed1fd17-b5df-41da-b75f-aa525925b530@m11g2000vbl.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

You don't need CATS in macro language to concatenate strings. There may be some useful application of CATS in macro language but this it not one of them.

9223 %let string = THE_TIME_IS_&hhmm; 9224 %put string = &string; string = THE_TIME_IS_0905

On 10/8/09, ajs2004@bigfoot.com <ajs2004@bigfoot.com> wrote: > The program below sets up a variable &hhmm with a value of '0905'. > > If I use the CATS function in the data step, it returns, as I expect, > > string=THE_TIME_IS_0905 > > but if I use the CATS function from the %SYSFUNC function, the result > is different: > > string=THE_TIME_IS_905 > > ... with the leading '0' disappeared. > > How can that possibly happen? "Macro variables contain only character > data", according to > http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293823.htm > > So I don't understand how the leading '0' can have been removed, when > it should never have been treated as numeric in the first place. Is it > a bug, or am I missing something? > > How can I put it right? Does it need some sort of macro quoting > function somewhere? > > _____________________________________________________________ > > %let t = '09:05't; > > %let hhmm = %sysfunc(compress(%sysfunc(putn( &t, tod5.)),":")); > %put hhmm = &hhmm; > > %let string = %sysfunc ( cats( THE_TIME_IS_, &hhmm ) ); > %put string = &string; > > data _null_; string = cats ( "THE_TIME_IS_", "&hhmm" ); put string=; > run; > > _____________________________________________________________ > > 1 %let t = '09:05't; > 2 > 3 %let hhmm = %sysfunc(compress(%sysfunc(putn( &t, > tod5.)),":")); > 4 %put hhmm = &hhmm; > hhmm = 0905 > 5 > 6 %let string = %sysfunc ( cats( THE_TIME_IS_, &hhmm ) ); > 7 %put string=&string; > string=THE_TIME_IS_905 > 8 > 9 data _null_; string = cats ( "THE_TIME_IS_", "&hhmm" ); put > string=; run; > > string=THE_TIME_IS_0905 > _____________________________________________________________ >


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