Date: Mon, 21 Jul 2008 11:19:34 -0700
Reply-To: Adriano Rodrigues <adriano@GPP.COM.BR>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Adriano Rodrigues <adriano@GPP.COM.BR>
Subject: RES: How to pick right records
In-Reply-To: <b7f239c7-bf01-4534-ab54-fc7ed7bf5398@f36g2000hsa.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"
One way with transpose:
data test;
attrib
Person length = $10
Test_nr length = $1
Judgement length = $40
;
infile datalines truncover;
input
@01 Person $10.
@15 Test_nr $1.
@20 Judgement $40.
;
datalines;
Person1 1 ask for more info
Person1 2 approved
Person2 1 not approved
Person2 2 ask for more info
Person2 3 approved
Person3 1 ask for more info
;
run;
proc transpose data=test out=new;
by person;
var judgement;
run;
* you can rename your columns in data new;
data wanted;
set new;
proc print;
where col1^='approved' and col2^='approved' and col3^='approved';
id person;
run;
Adriano
-----Mensagem original-----
De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] Em nome de Rune
Runnestø
Enviada em: segunda-feira, 21 de julho de 2008 02:10
Para: SAS-L@LISTSERV.UGA.EDU
Assunto: How to pick right records
Is there a simple way to solve this problem?
data test;
attrib
Person length = $10
Test_nr length = $1
Judgement length = $40
;
infile datalines truncover;
input
@01 Person $10.
@15 Test_nr $1.
@20 Judgement $40.
;
datalines;
Person1 1 ask for more info
Person1 2 approved
Person2 1 not approved
Person2 2 ask for more info
Person2 3 approved
Person3 1 ask for more info
;
run;
/*
Here I want to keep only the records of persons who have not
'approved' in any of the fields for Judgement for this person.
In the example over, only the record with Person3 shall remain in the
data set TEST2.
The data set TEST is sorted by PERSON and TEST_NR.
*/
data test2;
set test;
?????
run;
Hope for an answer to solve this problem.
Rune