Contributor
Posts: 59

# intck or month functions

Hi,

I need to calculate the number of months between two dates.
the data like this:

data a;
informat date9.;
input opendate;
cards;
Hh Date Active
09-Nov-84
01-Jan-78
15-Jun-87
10-May-82
01-Nov-72
18-May-94
29-Apr-85
18-Jul-97
02-Feb-96
16-Aug-88
01-Nov-99
22-Jun-00
10-Aug-90
08-May-98
01-Jan-78
08-Oct-02
02-Jan-89
20-Feb-04
04-Apr-75
20-Aug-04
23-Jun-04
16-Jul-04
01-Jun-92
25-Aug-94
06-Mar-07
15-May-06
05-Mar-07
26-Aug-02
18-Nov-01
11-Jun-96
03-Dec-99
30-Jul-08
16-Apr-07
14-May-07
18-Jun-08
13-Jul-07
06-Dec-02
01-Jan-78
05-Oct-95
06-May-08
04-Sep-98
19-Sep-09
31-Oct-08
01-Nov-08
01-Oct-92
20-Sep-07
30-May-97
22-May-08
24-Jul-09
01-Dec-89
;
run;

I need to calculate how many monthes between open date to now. Could someone help me out ?

Thanks,

Ching

T
Super Contributor
Posts: 3,176

## Re: intck or month functions

Yes, use the INTCK function along with your date-variable and the TODAY() function as one of your arguments.

Scott Barry
SBBWorks, Inc.

Recommended Google advanced search arguments, this topic/post:

using sas dates site:sas.com

comparing sas dates intck site:sas.com
Contributor
Posts: 59

## Re: intck or month functions

Thanks for your feedback.

I know it is easy to calculate for single date variable. How to use intck function in Data Step to calculate many date vairables.

mage=INTCK(’MONTH’,’date’D,’30Oct2009’D)

many thanks,
Super Contributor
Posts: 3,176

## Re: intck or month functions

You can declare and use an ARRAY which would list your "date variables", as shown below:

DATA _NULL_;
ARRAY ADATES (*) DATE1-DATE3;
FORMAT DATE: DATE9.;
* LOAD UP SOME DATE VARIABLES FOR AN DEMO. ;
DO MN=1 TO DIM(ADATES);
ADATES(MN) = INTNX('MONTH',TODAY(),MN,'SAMEDAY');
END;
DO I=1 TO DIM(ADATES);
* DO SOME CODE FOR EACH VARIABLE IN THE ARRAY. ;
END;
PUTLOG _ALL_;
RUN;

Scott Barry
SBBWorks, Inc.

Recommended Google advanced search argument, this topic/post:

data step array processing site:sas.com
Occasional Contributor
Posts: 10

## Re: intck or month functions

Please try this one.

data a;
input opendate anydtdte.;
format opendate date9.;
today = put(today(), date9.);
mth = intck("month", opendate, today());
cards;
09-Nov-84
01-Jan-78
15-Jun-87
10-May-82
01-Nov-72
18-May-94
29-Apr-85
18-Jul-97
02-Feb-96
16-Aug-88
01-Nov-99
22-Jun-00
10-Aug-90
08-May-98
01-Jan-78
08-Oct-02
02-Jan-89
20-Feb-04
04-Apr-75
20-Aug-04
23-Jun-04
16-Jul-04
01-Jun-92
25-Aug-94
06-Mar-07
15-May-06
05-Mar-07
26-Aug-02
18-Nov-01
11-Jun-96
03-Dec-99
30-Jul-08
16-Apr-07
14-May-07
18-Jun-08
13-Jul-07
06-Dec-02
01-Jan-78
05-Oct-95
06-May-08
04-Sep-98
19-Sep-09
31-Oct-08
01-Nov-08
01-Oct-92
20-Sep-07
30-May-97
22-May-08
24-Jul-09
01-Dec-89
;
run;
Discussion stats
• 4 replies
• 398 views
• 0 likes
• 3 in conversation