LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 27 Nov 2007 13:58:29 -0500
Reply-To:   Jack Clark <JClark@CHPDM.UMBC.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jack Clark <JClark@CHPDM.UMBC.EDU>
Subject:   Re: aggregate or restructure data set
Comments:   To: Peter Müller <mortal@GMX.LI>
In-Reply-To:   A<200711271835.lARBr04l003413@malibu.cc.uga.edu>
Content-Type:   text/plain; charset="iso-8859-1"

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


Back to: Top of message | Previous page | Main SAS-L page