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
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;
Can you post sample data?
The TimeInJobYears and TimeInJobMonths fields hold a numeric number.
Name TimeInJobYears TimeInJobMonths
John Smith 6 4
Alan Turner 2 8
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;
Thanks, that worked perfectly.
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.