Date: Mon, 20 Jun 2011 16:10:23 -0400
Reply-To: "Bian, Haikuo" <HBian@FLQIO.SDPS.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Bian, Haikuo" <HBian@FLQIO.SDPS.ORG>
Subject: Re: A Count question
In-Reply-To: <201106201908.p5KAmBJm006027@willow.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
One of data step options (just for the purpose of practice) could be:
data have;
infile cards;
length subject $4.
parts $2.
;
input subject parts;
cards;
1001 1
1001 1
1001 2
2003 3
2003 4
2003 10
run;
proc sort data=have;
by subject parts;
run;
data need (drop=parts rename=n=parts);
do until (last.subject);
set have ;
by subject parts;
if first.parts then n+1;
end;
output;
n=0;
run;
proc print;run;
Regards,
Haikuo
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tom Smith
Sent: Monday, June 20, 2011 3:09 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: A Count question
I have a following dataset with two variables: subject (Charecter) parts
(numeric):
subject parts
------- -----
1001 1
1001 1
1001 2
2003 3
2003 4
2003 10
I need to count how many different values for the variable "part" by
subject is available.
the output should be as below:
subject parts
------- -----
1002 2
2003 3
Thanks a lot.
-----------------------------------------
Email messages cannot be guaranteed to be secure or error-free as
transmitted information can be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The
Centers for Medicare & Medicaid Services therefore does not accept
liability for any error or omissions in the contents of this
message, which arise as a result of email transmission.
CONFIDENTIALITY NOTICE: This communication, including any
attachments, may contain confidential information and is intended
only for the individual or entity to which it is addressed. Any
review, dissemination, or copying of this communication by anyone
other than the intended recipient is strictly prohibited. If you
are not the intended recipient, please contact the sender by reply
email and delete and destroy all copies of the original message.