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 (November 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 12 Nov 2007 16:05:21 -0500
Reply-To:     Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject:      Re: Does substring apply to NUMERIC vars?
Comments: To: Syb it <sas_datalover@yahoo.com>
In-Reply-To:  <1601.64615.qm@web62210.mail.re1.yahoo.com>
Content-Type: text/plain; charset="us-ascii"

If the variable shows up as a numeric type in a PROC CONTENTS, DICTIONARY.columns, column attributes display, you may either transform the numeric value or convert it to a string:

str=REVERSE(SUBSTR(REVERSE(PUT(var,7.)),1,4));

converts the numeric value to a string that has the last four digits of var. One could then convert the string back to a numeric variable with the INPUT() function.

Make sure that you expect what the composite function yields when a number displays less than seven digits. Are you expecting leading zeroes, for example? S

-----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Syb it Sent: Monday, November 12, 2007 3:41 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Does substring apply to NUMERIC vars?

I have a varaible which is 7 digits long.. i need to create a new variable with the last four digits, while dropping the leading zero in cases where it was there (forth digit). Any ideas? I have tried the substring function, but... nothing yet.

__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com


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