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 (March 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 3 Mar 2000 20:51:31 GMT
Reply-To:     xzhou80@MY-DEJA.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         xzhou80@MY-DEJA.COM
Organization: Deja.com - Before you buy.
Subject:      Re: Strange variable behaviour

Try this one ! I guess the default of length for stuff is $8.

Thanks! zhou

data data4; length stuff $3.; if _n_=1 then set data1; set data2; array search(3) $ a b c; do i=1 to 3 until(hit); stuff=trim(left(search{i})); stuff2="*****"||stuff||"*****"; hit=index(names,stuff); end;

proc print; run;

In article <BD12CBAE6A73D211B00300A0C99D6E49011E611D@EXCHANGE5.CSMC.EDU>, "Philp, Stephen R." <Stephen.Philp@CSHS.ORG> wrote: > Okay, I'll admit my array processing is in its infancy, but for the life of > me, I can not work this one out in my head. I would love to know the why > behind the works. > *First set up a little data; > data data1; > input a $ b $ c $; > cards; > it of ash > ; > > data data2; > infile cards truncover; > input names $40.; > cards; > angelas ashes > star wars > let it ride > ; > *now do some processing; > *this construct works and hit gets populated correctly; > data data3; > if _n_=1 then set data1; > set data2; > array search(3) $ a b c; > do i=1 to 3 until(hit); > hit=index(names,trim(left(search{i}))); > end; > proc print data=data3; > run; > *this construct does not work and hit never gets populated; > data data4; > if _n_=1 then set data1; > set data2; > array search(3) $ a b c; > do i=1 to 3 until(hit); > stuff=trim(left(search{i})); > hit=index(names,stuff); > end; > proc print data=data3; > run; > > I believe that stuff is not inheriting the correct attributes, and some > padding with spaces is happening? But if I left and trim stuff after just > assigning it: > stuff=search{i}; > stuff=trim(left(stuff)); > It still doesn't work. I suspect a length statement would have solved this > but would not be easily facilitated in this piece of code (production code > is dynamic). > Anyone care to pass on some Guru knowledge on this? > Thanks again, > Stephen >

Sent via Deja.com http://www.deja.com/ Before you buy.


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