Help using Base SAS procedures

Date difference

Reply
Contributor
Posts: 32

Date difference

I am having two dates in the SAS dataset.
x y
200801 200903
200102 200111


I need to find the number of months these dates apart.

I have used intck but answer looks different.

Can some one help?
Contributor
Posts: 32

Re: Date difference

I got it ..

Below are my original dates :

EFdt PEDt
20100101 201006
20000612 200009


I used this equation to get the difference..


AGE = intck('month',MDY(mod(int(EFDT/100),100),mod(EFDT,100),int(EFDT/10000)),
MDY(mod(PEDT,100),1,int(PEDT/100)));
PROC Star
Posts: 7,474

Re: Date difference

Your code would be a lot simpler if you input the dates as dates rather than numbers. E.g.:
[pre]
data want;
informat EFdt yymmdd8.;
informat PEDt yymmn6.;
input EFdt PEDt;
age=intck('month',EFdt,PEDt);
cards;
20100101 201006
20000612 200009
;
[/pre]
Art
-------
> I got it ..
>
> Below are my original dates :
>
> EFdt PEDt
> 20100101 201006
> 20000612 200009
>
>
> I used this equation to get the difference..
>
>
> AGE =
> intck('month',MDY(mod(int(EFDT/100),100),mod(EFDT,100)
> ,int(EFDT/10000)),
> MDY(mod(PEDT,100),1,int(PEDT/100)));
Contributor
Posts: 32

Re: Date difference

Thanks Art..
Ask a Question
Discussion stats
  • 3 replies
  • 196 views
  • 0 likes
  • 2 in conversation