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 (May 1996, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 22 May 1996 14:13:20 -1000
Reply-To:     Chun Huang <CHUN@MANA.MEDSURF.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Chun Huang <CHUN@MANA.MEDSURF.COM>
Organization: Mana Institute
Subject:      Re: Counting the number of observations
Comments: To: Chien-Hua Wu <cwu@MATH.UNL.EDU>, Chien-Hua Wu <cwu@MATH.UNL.EDU>

Date: Wed, 22 May 1996 18:28:16 GMT Reply-to: Chien-Hua Wu <cwu@MATH.UNL.EDU> From: Chien-Hua Wu <cwu@MATH.UNL.EDU> Organization: University of Nebraska--Lincoln Subject: Counting the number of observations To: Multiple recipients of list SAS-L <SAS-L@VM.MARIST.EDU>

I have a difficulty to count the number of the same element and put it to the other column as a variable. The original data set and the new data set will be as follows.

Original data set (contain 4 different elements which are 2 3 4 and 8): 2 2 3 3 3 4 4 4 8 8

New data set (second column is the number of the same element in first column): 2 2 3 3 4 3 8 2

I am appreciated any help.

Jack.

ps. Thanks for those people answer my previous question.

Try this:

data test; input element; cards; 2 2 3 3 3 4 4 4 8 8 ; run; proc sort data=test; by element; run;

data test2; set test; by element; if first.element then count=0; count+1; if last.element; run;

proc print; run;

Chun Huang, Ph.D. Hawaii Osteoporosis Center Email: chuang@mana.medsurf.com


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