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

Hi guys,

I have information on employees' salaries and the end and start date of the time they worked at the company. I wish to work out the Total Sum of Salaries for 2014, but many staff left halfway through the year so they only get a percentage of their whole salary. So how do I find out the percentage of the salary they got and then sum it together to get the Sum of Salaries using the Query Builder?  q

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

t2.end_date- '01jan2014'd

The underlined part is a date literal, which means one that humans understand. The internal numeric value that SAS uses for that date is 19724.

View solution in original post

5 REPLIES 5
ballardw
Super User

Actually if this was my project I would take the information to calculate a daily rate (unless hourly seems more appropriate and that information is available, The calculate the number of days as

DaysAtSalary = EndDate - StartDate; /* assumes you have SAS date values*/

Then using any of the report procedures such as Proc Report, Tabulate or even Means ask for the sum of the daily salary values and WEIGHT by the number of days at that salary.

agreekgod
Calcite | Level 5

The StartDates go way back, not to 2014 which is the only year that I want to find out about. I have tried to make a new column in the Query Builder with the expression so that I can find out how many days they have worked in 2014.

t2.end_date-01jan2014

But I keeps on saying that Query Syntax is not valid

ballardw
Super User

us '01JAN2014'd the quotes and d tell sas to treat the value as a date literal.

OR you can get the day of the year as Mod(juldate(t2.end_date),1000)

agreekgod
Calcite | Level 5

How do I treat date as literal?

ballardw
Super User

t2.end_date- '01jan2014'd

The underlined part is a date literal, which means one that humans understand. The internal numeric value that SAS uses for that date is 19724.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2085 views
  • 3 likes
  • 2 in conversation