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
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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