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 (October 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 20 Oct 2003 11:19:32 -0400
Reply-To:     "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Subject:      Re: IF-THEN recode problem
Comments: cc: Dave Sorensen <Dave.Sorensen@JUR.KU.DK>
Content-Type: text/plain

first examine a contents of your original data set: Old your error messages suggest that Number is numeric not character and that you may have a different name for Street

hard coding these fixes will eventually cause you much grief I suggest looking at functions index scan substr verify attrib Number length = $ 12 Street length = $ 32 Address length = $ 44 %*= sum(length(Number Street)); ; if index(Address,'0123456789') then do; Number = scan(Address,1); Space = index(Address,' '); Street = substr(Address ,Space + 1 ,length(Address) - Space -1); end;

Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov

--> cheerful provider of UNTESTED SAS code from the Clue?Gee!Wrx <-- see also: http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0310A&L=sas-l&P=R5913

> From: Dave Sorensen [mailto:Dave.Sorensen@JUR.KU.DK] > I have three variables: > NUMBER is a house number > STREET is a street name > ADDRESS is the full Address (house number and street) > > All were input as character variables. > > Clean, good address data look like this: > > NUMBER STREET ADDRESS > 25 JONES 25 JONES > 122A 2ND AVE 122A 2ND AVE > > But I also have some problematic data that look like > this (number is missing. Street inadvertently includes number): > > NUMBER STREET ADDRESS > 83 MAPLE 83 MAPLE > 42 PINE 42 PINE > > To fix these cases, I've tried running: > Data new; > Set old; > IF address='83 MAPLE' THEN number='83' and street='MAPLE'; > IF address='42 PINE' THEN number='42' and street='PINE'; > RUN; > > This results in the message: > NOTE: Character values have been converted to numeric > values at the places given by: > (Line):(Column). > ####:## > NOTE: Numeric values have been converted to character > values at the places given by: > (Line):(Column). > ####:## > NOTE: Invalid numeric data, 'MAPLE' , at line #### column ##. > etc. > > What is wrong with my IF THEN statements? I know > this is basic, but I've spent hours on it.


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