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

Hi I am trying to calculate a start date of employment usig the variables TimeInJobYears and TimeInJobMonths

Is there anyway that I can use these two fields to calculate when a person started work, I was thinking along the lines of todays date -  (TimeInJob
Years + TimeInJobMonths)

Any help would be greatly appreciated, Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Here is one approach, please note, I choose the beginning of the month as the date. You chould select end, middle as well.

data have;

input Name  & $12.        TimeInJobYears     TimeInJobMonths ;

cards;

John Smith      6                         4

Alan Turner     2                          8

;

data want;

set have;

start_dt=intnx('month',today(),-TimeInJobYears*12-TimeInJobMonths, 'b');

format start_dt date9.;

run;

proc print;run;

View solution in original post

5 REPLIES 5
Hima
Obsidian | Level 7

Can you post sample data?

robwork
Calcite | Level 5

The TimeInJobYears and TimeInJobMonths fields hold a numeric number.

Name          TimeInJobYears     TimeInJobMonths

John Smith      6                         4

Alan Turner     2                          8

Haikuo
Onyx | Level 15

Here is one approach, please note, I choose the beginning of the month as the date. You chould select end, middle as well.

data have;

input Name  & $12.        TimeInJobYears     TimeInJobMonths ;

cards;

John Smith      6                         4

Alan Turner     2                          8

;

data want;

set have;

start_dt=intnx('month',today(),-TimeInJobYears*12-TimeInJobMonths, 'b');

format start_dt date9.;

run;

proc print;run;

robwork
Calcite | Level 5

Thanks, that worked perfectly.

Linlin
Lapis Lazuli | Level 10

how about:

data have;

input TimeInJobYears TimeInJobmonth;

cards;

5 10

6 11

;

data want;

set have;

start_date=intnx('month',today(),-(12*TimeInJobYears+TimeInJobYears),'m');

format start_date mmddyy10.;

run;

proc print;run;

                                   TimeIn       TimeIn

                     Obs    JobYears    Jobmonth    start_date

                      1         5          10       10/16/2006

                      2         6          11       09/15/2005

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

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1358 views
  • 0 likes
  • 4 in conversation