Date: Thu, 7 Sep 2006 16:21:18 -0400
Reply-To: Peter Constantinidis <peter@CONSTANTINIDIS.CA>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Constantinidis <peter@CONSTANTINIDIS.CA>
Subject: Re: Trying to figure out the best way to count unique
observations by variable in a dataset
In-Reply-To: <BAY123-F4A50B19ABA44115EBB424DE360@phx.gbl>
Content-Type: text/plain; charset=WINDOWS-1252; format=flowed
Hi:
This is the code I'm using now for the proc summary:
proc summary data=fy20032004 missing nway print;
class FISCALYEAR LEAVE_CoDe;
var actLhrs JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC;
output out=Y0304 sum= n(id)=test;
run;
the n(id)=test is making a new variable which is almost what I'm after.
For code 952 for example it will display a value of 21, which is the n
of all observations for that specific code.
Doing a proc frequency I see:
EMPLID Frequency
Percent Frequency Percent
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
000205 1
4.76 1 4.76
000530 2
9.52 3 14.29
000716 1
4.76 4 19.05
001303 2
9.52 6 28.57
001682 1
4.76 7 33.33
001867 2
9.52 9 42.86
002670 1
4.76 10 47.62
003360 1
4.76 11 52.38
003399 2
9.52 13 61.90
003850 2
9.52 15 71.43
004359 2
9.52 17 80.95
005827 2
9.52 19 90.48
008597 1
4.76 20 95.24
009057 1
4.76 21 100.00
And again we see 21.. but if we count the unique appearances, we count
only 14 uniques.. and that's what I'm trying to get output.. to have
it say 14 instead of 21 that it does now.
I tried doing first.emplid in the data set, but that doesn't work
because the same person can file in other codes, and if they show up
in an earlier code, they are removed from all succeeding codes.. it
would have to be unique ids, for each code..