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 (June 2002, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 13 Jun 2002 12:50:45 -0400
Reply-To:     "Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM>
Subject:      Re: FW: repost : how to get a non zero value for each obs ( chall
              e nge problem)
Comments: To: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Content-Type: text/plain; charset=iso-8859-1

Sig,

I have thought of this, but abstained - not because of the repeated PUT() calls, but because the solution presumes the ahead-of-the-time knowledge about the number of digits in each number. Using the expression

input(left(tranwrd(peekc(addr(mon1),32),put(0,rb8.),'')),rb8.) ;

does not. In fact, non-zero elements can assume any numeric value at all.

Kind regards, ==================== Paul M. Dorfman Jacksonville, FL ====================

> -----Original Message----- > From: Sigurd Hermansen [mailto:HERMANS1@WESTAT.COM] > Sent: Thursday, June 13, 2002 11:40 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: FW: repost : how to get a non zero value for each obs ( > challe nge problem) > > > Quentin McMullen sent this one variable definition, no array, > and no loop > solution directly to me: > > data abc; > input subject mon1 mon2 mon3 mon4 ; > > enter=input(compress(put(mon1,1.)||put(mon2,1.)||put(mon3,1.)| > |put(mon4,1.), > '0'),1.); > datalines; > 1 0 0 2 0 > 2 2 0 5 0 > 3 4 2 7 0 > 4 0 1 5 0 > 5 2 3 . 7 > ; > run; > > His solution has one less variable definition than the one I > have in mind. > One drawback: it repeats the calls of the PUT() function. > > Anyone else accept the challenge? > > Sig > > -----Original Message----- > From: Andreas Gr|ninger [mailto:andreas.grueninger@LFL.BWL.DE] > Sent: Thursday, June 13, 2002 8:02 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: FW: repost : how to get a non zero value for each obs > > > Your and Paul's solution (sligthly modified ) gives a > one-step solution > without additional variables. > > data abc; > input subject mon1 mon2 mon3 mon4 ; > ARRAY mon mon:; > DO OVER mon; > IF (mon > 0) THEN DO; > enter = mon; > LEAVE; > END; > END; > datalines; > 1 0 0 2 0 > 2 2 0 5 0 > 3 4 2 7 0 > 4 0 1 5 0 > 5 2 3 . 7 > ; > run; >

Blue Cross Blue Shield of Florida, Inc., and its subsidiary and affiliate companies are not responsible for errors or omissions in this e-mail message. Any personal comments made in this e-mail do not reflect the views of Blue Cross Blue Shield of Florida, Inc.


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