BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have data in field date1 = 200702 and date= 200608

I need the result of date1-date2 = 6 months. How can i get it ?
3 REPLIES 3
deleted_user
Not applicable
the function you're looking for is intck. when given two date values, it returns the number of specified boundaries between the two values.

if you've got actual date values, you'll probably want to use those. i assumed you didn't so there is some conversion from 200702 to '01FEB2007'd.

[pre]
data temp;
date1 = 200608;
date2 = 200702;
d1 = input(put(date1, 6.), yymmn6.);
d2 = input(put(date2,6.), yymmn6.);
format d1 d2 date9.;
months = intck('month',d1, d2);
run;
[/pre]



Message was edited by: RichardK
added link to sas documentation
trying cynthia's tip
deleted_user
Not applicable
sorry about the format of the data step above...these forums don't seem to like html tags

data temp;
date1 = 200608;
date2 = 200702;
d1 = input(put(date1, 6.), yymmn6.);
d2 = input(put(date2,6.), yymmn6.);
format d1 d2 date9.;
months = intck('month',d1, d2);
run;
Cynthia_sas
Diamond | Level 26
Richard:
To code the equivalent of the PRE tags, do not use the LT and GT symbols, instead use square brackets.
'[' pre ']'
'[' /pre ']' without the spaces and quotes

[pre]
some code
some more code
[/pre]

cynthia

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 3 replies
  • 1724 views
  • 0 likes
  • 2 in conversation