BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robm
Quartz | Level 8

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?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

3 REPLIES 3
Reeza
Super User
Unfortunately, proc tabulate cannot generate unique counts 😞

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.
ballardw
Super User

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.

harlananelson
Fluorite | Level 6

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3421 views
  • 1 like
  • 4 in conversation