Hi people,
I have searched in the google and forum but did not find the solution,
here is my problem:
I have two column in my table date1 and date2 , columns are "numeric" and the date formats represents YYYYMM
date1 date2 datediff
--------- ----------- ----------------
201303 201310 ??
201211 201305 ??
I want to find how many month difference between these two date
according to example it must be 7 and the second row must be 6 month
but i could not find how to calculate in sas enterprise guide 5.1 ?
Hi,
Please try the below code
data have;
input date1 date2;
date1_=input(strip(put(date1,6.))||'01',yymmdd10.);
date2_=input(strip(put(date2,6.))||'01',yymmdd10.);
datediff=intck('month',date1_,date2_);
cards;
201303 201310
201211 201305
;
Thanks,
Jag
Hi,
Please try the below code
data have;
input date1 date2;
date1_=input(strip(put(date1,6.))||'01',yymmdd10.);
date2_=input(strip(put(date2,6.))||'01',yymmdd10.);
datediff=intck('month',date1_,date2_);
cards;
201303 201310
201211 201305
;
Thanks,
Jag
Thank you very much,
all my best wishes with you in your life
This should do it.
data work.cd;
input date1 date2;
datalines;
201303 201310
201211 201305
;
run;
data work.temp;
set work.cd;
datediff=intck('MONTH', input(put(date1, 6.), yymmn6.), input(put(date2, 6.), yymmn6.));
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: