BookmarkSubscribeRSS Feed
ganeshsas764
Obsidian | Level 7

Hi ,

can you please help on  the queary ,

 

data sample;

datediff=yrdiff('17may1991'd),today(),"ACT/ACT");

run;

 

I need answer Like this::-"26 years 1 months 10 days"

5 REPLIES 5
Rick_SAS
SAS Super FREQ

You want to use the INTCK and INTNX functions, Read the article and modify the technique in the article 'INTCK and INTNX: Two essential functions for computing intervals between dates in SAS," which gives ages in the form Y YEARS and D DAYS. The article links to the documentation for those functions and a few SAS Global Forum papers that are worth reading.

 

art297
Opal | Level 21

I tested the following on a number of dates and it appears to meet all posibilities:

data sample;
format date date9.; input date date9.; years=intck('year',date,today(),'C'); months=intck('month',date,today(),'C')-(years*12); if day(date) le day(today()) then days=day(today())-day(date); else days=intck('day',mdy(month(intnx('month',today(),-1,'same')), day(date), year(intnx('month',today(),-1,'same'))), today(),'C'); datediff=catx(' ',years,'years,',months,'months, and',days,'days'); cards; 17may1991 29jun2016 28jun2016 27jun2016 26jun2016 25jun2016 29may2016 28may2016 27may2016 26may2016 25may2016 ; run;

Art, CEO, AnalystFinder.com

 

Rick_SAS
SAS Super FREQ

Nice. Looks pretty good, Art!

 

Just to be clear, we are all assuming that the DATE represents some event in the past, which seems to be the case for this question.

ganeshsas764
Obsidian | Level 7

super ,  Thank you 

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!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 966 views
  • 4 likes
  • 4 in conversation