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 (September 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 23 Sep 2009 08:37:52 -0400
Reply-To:     Kevin Xu <kevinsascontractor@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Kevin Xu <kevinsascontractor@GMAIL.COM>
Subject:      array?
Content-Type: text/plain; charset=ISO-8859-1

Hi,

I have a question:

I have a numerical variable, and I would like to compare it with a certain number of fixed numbers and choose the one closest

for example:

the number variable that can have numerical values, the fixed numbers are: 3,6,9,12,15, if the variable has value of 2, then I would like to change 2 to 3 because 3 is the closest number to 2. if the variable has a value of 7, then I want to change 7 to 6 because 6 is the closest number to 7. if the variable has a value of 4.5, then either 3 or 6 can be the answer.

I think I can use if statement, but I am wondering if an array or another easier method can do this?

Thanks for help!


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