I would like to do a two way proc freq table showing a list of all the departments, and then a distinct count of the employees that are a part of each department.
Without having each employee ID spread out horizontally with the count of records for each, i just want the distinct total of employees per department with records.
Any help would be appreciated.
Thanks!
Based on the way you expect the output to appear:
Without having each employee ID spread out horizontally with the count of records for each, i just want the distinct total of employees per department with records.
It doesn't sounds like you want a two-way frequency table.
Using this dummy data:
DATA WORK.HAVE;
FORMAT Dept $20. Employee $20.;
INPUT Dept Employee;
INFILE DATALINES DLM='|' DSD;
DATALINES;
Human Resources|Adam Apple
Accounting|Bill Bobington
Accounting|Chuck Cooper
Accounting|Donna Dillard
Human Resources|Edward Ekins
Sales|Fred Flintstone
;
I used this PROC FREQ logic to generate a list of all of the departments and a distinct count of employees for each department.
PROC FREQ DATA=WORK.HAVE; TABLES Dept /LIST MISSING NOPERCENT NOCUM; RUN;
And the resulting output that printed was this:
Dept Frequency
Accounting 3
Human Resources 2
Sales 1
A list of all of the departments from the dataset and a distinct count of the total employees from that department.
If this isn't what you were looking for, please provide some additional details (like dummy data that aligns to your actual dataset, a visual representation of what your expectations are for the final output, etc).
Hope this helps.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.