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 (August 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 18 Aug 2009 09:32:21 -0400
Reply-To:     Paul St Louis <pstloui@DOT.STATE.TX.US>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul St Louis <pstloui@DOT.STATE.TX.US>
Subject:      Excel lib from spreadsheet and Z3. Command

I often find a need to import an excel sheet:

LIBNAME GET "path - file.xls" HEADER=YES;

Then, in my data set, I take a numeric value, convert it to a character value and prepend leading zeroes and a 'C' character in front:

DATA FIPS_CTY_1511 ( DROP = F5 CNTY_NBR CTY ); LENGTH CTY $3. COUNTY $4.; SET GET.'FIPS County Number$'N (RENAME=(FIPCO__FIPS__FOR_Texas_State_Num = FIPS_CTY )); CTY = PUT(INPUT(CNTY_NBR,12.),Z3.); COUNTY = CATS('C',CTY); RUN;

What I don't understand is why there is a need to input the number as 12. when in reality it is only 3. If I declare the number to be anything less than 12, then SAS shows missing values.

The code works, I'm just curious why this is.....

Obs CTY COUNTY CNTY_NM FIPS_CTY DIST_NM 251 251 C251 Yoakum 501 Lubbock 252 252 C252 Young 503 Wichita Falls 253 253 C253 Zapata 505 Pharr

I use Proc Format and have a VALUE $CNAME. to convert the county number to a county name so that C241 becomes Yoakum in my output.


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