Date: Mon, 27 Dec 2010 01:11:50 -0500
Reply-To: Søren Lassen <s.lassen@POST.TELE.DK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Søren Lassen <s.lassen@POST.TELE.DK>
Subject: Re: Is there an easier way to solve this?
Content-Type: text/plain; charset=ISO-8859-1
Art,
How about this:
data address;
length firstname lastname address $20 city $40 state $2 zip $5;
informat zip state city $revers.;
input firstname lastname /
Address & /
@;
_infile_=reverse(_infile_);
input zip state city &;
cards;
John Doe
33 10 Av.
Uptown, Smalltown XX 12345
;run;
Regards,
Søren
On Sun, 26 Dec 2010 11:07:11 -0500, Arthur Tabachneck <art297@ROGERS.COM>
wrote:
>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
|