Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! Comparing 2 SAS data sets with one common variable 1

Status
Not open for further replies.

cosmid

Programmer
Feb 14, 2008
73
US
I have 2 SAS dataset. dataset a has the total number of employees for each dept. dataset b has the total number of employees of interest for each dept. I need to generate a histogram that list each dept with the total of number of employees, the number of employees of interest, and the percentage. Both dataset have the following format: SSN, Dept, Job_Title, and Num_Emp.

For example,

Dept Total Emp Num of Emp Percentage
Machine Shop 80 20 25%
Analysts 50 10 20%


How do I do that? The only way I know how to do it is manually. I can have a freq table for each dataset and then just write down the numbers and calculate the percentage myself. But that doesn't give me a histogram.

thanks in advance for the help!
 
you've said "total" number of employees is in dataset a ... but that both datasets have SSN (American social security number? Which would be unique), which would indicate that there is one record per employee in each dataset?

If so, just do a proc summary for both datasets, eg:

proc summary data=a nway;
class dept;
output out=a_cnt;
run;

and similarly for b, then merge a_cnt and b_cnt by dept (on the assumption that the values of dept match where they should , there's no trailing blanks, no variations of dept name etc ... may be easier to construct a numeric composite variable for dept).

also be sure to drop any common variables from a_cnt and b_cnt that won't be used in the by statement on the merge.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top