Help using Base SAS procedures

proc tabulate and filtering unique colum value

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 77
Accepted Solution

proc tabulate and filtering unique colum value

I have a proc tab that does a count as the default statistic

 

 

  proc tabulate data=WORK.HRIR99991 missing contents = ' '  S=[foreground=highlight.];
   class BUSINESS_UNIT_DESC GENDER_CODE DEPARTMENT_DESC;
   var fte;
   keylabel Sum = " ";


   table  BUSINESS_UNIT_DESC='Business Unit' * N='Record Count'/
                  contents = ' ' misstext=' ' box={label="&boxlabel"};

RUN;

 

 

this gives ne a count of the number of records in the data set however each record has an employees HR ID number in it  (called HRID)

what I would like to do is just count each unique HRID once to get a head count is tehre a way to do that in proc tab?


Accepted Solutions
Solution
‎12-01-2015 02:36 PM
Super User
Posts: 10,490

Re: proc tabulate and filtering unique colum value

If your HRID varialbe is actually numeric you could make it a VAR variable and ask for the N statistic. That gives a count. When it is a CLASS variable then you get the individual values. But VAR must be numeric not a character variable containing digits.

View solution in original post


All Replies
Super User
Posts: 17,801

Re: proc tabulate and filtering unique colum value

Unfortunately, proc tabulate cannot generate unique counts Smiley Sad

Depending on what your'e doing you can consider adding a 1 to the first record and the remaining as 0 and then sum that field, but if you're cross tabbing data that won't always work because you need to count by groups.
Solution
‎12-01-2015 02:36 PM
Super User
Posts: 10,490

Re: proc tabulate and filtering unique colum value

If your HRID varialbe is actually numeric you could make it a VAR variable and ask for the N statistic. That gives a count. When it is a CLASS variable then you get the individual values. But VAR must be numeric not a character variable containing digits.

New Contributor
Posts: 2

Re: proc tabulate and filtering unique colum value

I wonder why and incorrect answer is marked as a solution.  N gives a count, but not a unique count. 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 386 views
  • 0 likes
  • 4 in conversation