Date: Fri, 6 Nov 2009 09:48:54 +0100
Reply-To: Fernández Rodríguez, Dani
<DFernandez@CST.CAT>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Fernández Rodríguez, Dani
<DFernandez@CST.CAT>
Subject: Re: how to flag out the old claims?
In-Reply-To: A<80dee373-b833-416f-baba-809a93f7cc9d@b15g2000yqd.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"
Here my solution is:
data have;
input clmno $ version;
cards;
AAA 001
AAA 001
AAA 002
AAA 002
BBB 001
CCC 001
CCC 002
CCC 002
CCC 003
;
run;
proc sort data=have out=need; by clmno descending version; run;
data compare_older;
set need;
by clmno descending version;
if first.clmno then output;
run;
data need;
merge need
compare_older (in=a);
by clmno descending version;
if not a then flag=1;
run;
* we sort the original dataset to the original state;
proc sort data=need ; by clmno version; run;
OUTPUT
clmno version flag
AAA 1 1
AAA 1 1
AAA 2 .
AAA 2 .
BBB 1 .
CCC 1 1
CCC 2 1
CCC 2 1
CCC 3 .
Daniel Fernandez
Barcelona.
-----Mensaje original-----
De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] En nombre de Ruby
Enviado el: dijous, 5 / novembre / 2009 16:09
Para: SAS-L@LISTSERV.UGA.EDU
Asunto: how to flag out the old claims?
Hi SAS experts,
I have a claim dataset and want to flag out the old version claims.
How can I do it in SAS? Thanks very much!
******* input *******
clmno version
AAA 001
AAA 001
AAA 002
AAA 002
BBB 001
CCC 001
CCC 002
CCC 002
CCC 003
********desired output *****
clmno version flag
AAA 001 1
AAA 001 1
AAA 002
AAA 002
BBB 001
CCC 001 1
CCC 002 1
CCC 002 1
CCC 003