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 (December 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 26 Dec 2010 22:35:02 -0500
Reply-To:     Nat Wooding <nathani@VERIZON.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <nathani@VERIZON.NET>
Subject:      Re: Is there an easier way to solve this?
In-Reply-To:  <000301cba573$d1fea620$75fbf260$@com>
Content-Type: text/plain; charset="us-ascii"

Max

That is neat and I don't have to take Excedrin in order to look at the code.

Nat -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of bbser 2009 Sent: Sunday, December 26, 2010 10:12 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Is there an easier way to solve this?

Wow, so many people like me are SASing while Christmasing.

Art

Alternatively, I tried using tranwrd().

data b; x="New York NY 85044"; Length zip $ 5 state $ 2 city $ 30; Zip=scan(x, -1); State=scan(x, -2); City=tranwrd(x, state||" "||zip, " "); run;

proc print; run;

Cheers, Max

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Arthur Tabachneck Sent: December-26-10 11:07 AM To: SAS-L@LISTSERV.UGA.EDU Subject: [SAS-L] Is there an easier way to solve this?

The following was a question that was raised on the SAS discussion forum. You are confronted with data that has 3 lines per subject, but the third line has variables that may contain embedded spaces, but there is only one space between variables.

The only suggestion I could think of was the one shown below. Is there an easier way?

data work.Address (drop=_:); infile cards; input FirstName $ LastName $ / Address $ 1 - 20 / _Third_Line & $80.; format City $10.; Zip=scan(_Third_Line,-1); State=scan(_Third_Line,-2); call scan(_Third_Line, -2, _position, _length); City=substr(_Third_Line,1,_position-1); cards; Lee Athnos 1215 Raintree Circle New York NY 85044 Heidie Baker 1751 Diehl Road Vienna VA 22124 ;

Thanks in advance, Art


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