01-27-2016 03:09 PM
I'm a new user of SAS and I'm learning how to use it more and more each day so please I apologize if this is a basic question.
I have built a process using SAS EG to help me identify turnover for our organization. In this process I need to calculate the total number of employees on average for a month. Below is a recap on what I have in the table:
CREATE TABLE WORK.QUERY_FOR_HISTAPPT AS
FROM HRMS.HISTAPPT t1
WHERE t1.DATECRED BETWEEN '20110630' AND '20110731' AND t1.EMP_ID NOT = '000000' AND t1.STUDTITL NOT = 'Y' AND
t1.OCC_CD NOT IN
) AND t1.SUBLOCCD NOT = 'ACAD';
Ok, So I am pulling in all employees in an appointed positions at the end of two months, so all records are in this one table. Now I want to see if I can get the average number of employees by position type for that timeframe. I can get the actual numbers in a summary table; however, the average is really what I need. Any help would be greatly appreciated!
01-27-2016 03:42 PM
Here's what I'm doing currently, I'm taking the summary table and dumping it into excel and then calculating the average by taking the total number of employees at the end of the two months, adding them together then dividing the total by 2.
=(total employees on 20110731) + (total employees on 20110831))/2
I have attached an image of the summary table.
01-27-2016 03:47 PM
But how are you generating that table? Is it through proc tabulate?
We need to see a sample of the data structure that you'd be working with in SAS.
01-27-2016 03:59 PM
Try changing the statistics requested - I'm assuming you're using a table builder of sorts.
Where it has N, you can add Mean
You can play around with it to see if generates what you need.
01-27-2016 06:36 PM
Okay, so when I look at the code for the summary table is does say Proc Tabulate. I am attaching a screenshot.
Run the Tabulate code with an Out=SummaryData on the proc statement. This will create a data set with the monthly totals.
Use that data to calculate the mean. Note that the summary variables in the dataset will have suffixes such as _sum added to them, so you can't just use the exact same tabulate code. But it shouldn't be horrific.
If we had an actual input data set example we could provide more exact code example.