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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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