Date: Mon, 22 May 2006 21:09:58 -0400
Reply-To: Ei-Wen Chang <ei-wen_chang@CTB.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ei-Wen Chang <ei-wen_chang@CTB.COM>
Subject: random delet from subgroups
I have to random delete some observations in subgroups from a master data
(STD). The rules are like following.
If form='A1', grade=2, ethnicity=H or I then random delete 5 cases from
this subgroup.
If form='A1', grade=3, ethnicity=B then random delete 9 cases from this
subgroup.
If form='A3', grade=2, then random delete 8 cases from this subgroup. (no
target ethnicity)
If form='A3', grade=7, and ethnicity='A' then random delete 6 cases from
this subgroup.
There are more form, grade, and ethnicity combinations that needs to be
excluded, so I don't want to hard code. If anyone can give me some
advices, I will appreciate your help. Following are my sample data.
data excluse;
infile cards missover;
input @1 form $2. @4 grade @6 ethnicity $2. @9 del_n;
cards;
A1 2 HI 5
A1 3 B 9
A3 2 8
A3 7 A 6
;
Data std;
do i=1 to 20;
form='A1';
grade=2;
ethnicity='H';
output;
form='A1';
grade=2;
ethnicity='I';
output;
form='A1';
grade=3;
ethnicity='B';
output;
form='A1';
grade=3;
ethnicity='I';
output;
form='A3';
grade=2;
ethnicity='A';
output;
form='A3';
grade=2;
ethnicity='I';
output;
form='A3';
grade=7;
ethnicity='A';
output;
form='A3';
grade=7;
ethnicity='A';
output;
form='A3';
grade=7;
ethnicity='B';
output;
end;
run;
Ei-Wen
|