Date: Wed, 16 May 2012 20:41:24 -0400
Reply-To: Nat Wooding <nathani@VERIZON.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <nathani@VERIZON.NET>
Subject: Re: datastep matching obs problem
In-Reply-To: <CAFRTgczegmbd8NpkLM5gfJnDKTCYGwDtp13gru_WcC2PmDV9TA@mail.gmail.com>
Content-Type: text/plain; charset="US-ASCII"
JD
Your explanation eludes me but it appears that if Parta is greater than
(meaning that in sort order, it would sort after partc) partc, then you want
to set partb to the value of partc.
The following code does this, at least for the example data that you
offered.
Nat Wooding
data have;
infile datalines missover;
input parta $2. @4 partb $2. @7 partc $2.;
datalines;
a1 a2
b1 b1 b2
b2 b1
c1 c1 c2
c1 c1 c2
c2 c1
;
data want;
set have ;
if parta gt partc then partb = partc;
run;
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of JD
Sent: Wednesday, May 16, 2012 8:22 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: datastep matching obs problem
I have a dataset and need to fill in data (var partb) such that if a value
is in partc and that same value is also in parta partb will then be filled
in with value from parta. I hope this example explains it better. Thank you.
data have;
infile datalines missover;
input parta $2. @4 partb $2. @7 partc $2.;
datalines;
a1 a2
b1 b1 b2
b2 b1
c1 c1 c2
c1 c1 c2
c2 c1
;
data want;
infile datalines missover;
input parta $2. @4 partb $2. @7 partc $2.;
datalines;
a1 a2
b1 b1 b2
b2 b1 b1
c1 c1 c2
c1 c1 c2
c2 c1 c1
;