|
Peter,
Here is one approach...
data have;
infile cards missover;
input ID Diag $;
cards;
1 A
1 b
1 c
2 b
2 c
3 A
3 b
3 f
3 g
4 g
4 y
;
run;
proc sql;
create table need as
select diag, count(*) as count
from have
where id in (select distinct id
from have
where upcase(diag) = 'A')
group by diag
;
quit;
proc print data = need;
run;
Jack Clark
Research Analyst
Center for Health Program Development and Management
University of Maryland, Baltimore County
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Peter Müller
Sent: Tuesday, November 27, 2007 1:36 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: aggregate or restructure data set
Dear list members,
i'm new to SAS and have a question concerning the restructuring or
aggregating of variables:
I've two variables:
The 1st is the ID and the 2nd are diagnostics for this patients.Everyone of
those can have different diagnostics.
I want to receive a dataset, that lists all additional diagnostics, when a
special diagnostic is true.
ID Diag
1 A
1 b
1 c
2 b
2 c
3 A
3 b
3 f
3 g
4 g
4 y
....
I want to have those diagnostics, when A has been found. in this case
for ID 1 and 3, so that the result looks like:
Diag
a 2
b 2
c 1
f 1
g 1
Thank you,
Peter Müller
|