LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (September 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 15 Sep 2008 18:08:34 -0400
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: Extracting data from a string to populate a new variable
Comments: To: donnelly.ryan.m@GMAIL.COM

Ryan,

Is there a chance that the solution might not require string searches? For example, does the first comma always represent a second address line?

If so, possibly something like the following might suffice:

data have; input address $50.; cards; 123 Main St., 8th Floor 222 8th St. 455 8th St., appt 9 ;

data want; set have; if index(address,",") gt 0 then do; address2=substr(address,index(address,",")+1); address=substr(address,1,index(address,",")-1); end; run;

Art -------- On Mon, 15 Sep 2008 13:59:55 -0700, RYan <donnelly.ryan.m@GMAIL.COM> wrote:

>Hello all you SAS-L'ers...here's my dilema, I hope you can help. > >I have some address data that needs to get cut up and put into >different variables, not just one big address variable. Specifically, >I have addresses like "123 Main St. 8th Floor" where I need to parse >out the "8th Floor" portion and put it into a new variable. > >So far I've identified all the records with the key phrase "8th" or >"Eight Floor" using the prxmatch function. However, I haven't been >able to devise a way to tell SAS to take that info and populate a new >variable with that string. I thought of using the substr function >however, their location in the string is not constant. > >Your help is greatly appreciated and I thank you in advance. > >All the best, >Ryan


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