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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 960 views
  • 0 likes
  • 4 in conversation