BookmarkSubscribeRSS Feed
sasg
Calcite | Level 5
I'm learning sas......Trying to do below example....Please suggest me how to do it.
Pls post the code.

Below is the sample data.

input:

id date status days
112 03/02/09 Approved 4
112 03/03/09 Refferal 3
112 03/04/09 shipped 2
112 03/06/09 shipped 3
113 04/01/08 Refferal 2
113 04/02/09 Approved 1
113 04/03/09 Ahipped 1

I want to exclude the recordswith perticular id in output,if first date status is not equal to refferal.

Output:

id date status days
113 04/01/08 Refferal 2
113 04/02/09 Approved 1
113 04/03/09 Ahipped 1

Thanks,
sasg
1 REPLY 1
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello SASG,

This is a solution:
[pre]
data i;
input id date ANYDTDTE9. status $ days;
format date date7.;
datalines;
112 03/02/09 Approved 4
112 03/03/09 Refferal 3
112 03/04/09 shipped 2
112 03/06/09 shipped 3
113 04/01/08 Refferal 2
113 04/02/09 Approved 1
113 04/03/09 Ahipped 1
run;
proc sort data=i;
by id date;
run;
data r;
retain drop;
set i;
if FIRST.id then drop=0;
if FIRST.id and UPCASE(status) NE "REFFERAL" then drop=1;
if drop=0 then output;
by id;
drop drop;
run;
[/pre]
Sincerely,
SPR

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 1 reply
  • 915 views
  • 0 likes
  • 2 in conversation