Interview Questions   Tutorials   Discussions   Programs   Videos   

SAS - Explain intnx, intcx functions?

asked mar September 20, 2014 06:30 AM  

Explain intnx, intcx functions?


1 Answers

answered By vishnoiprem   0  

INTNX function advances a date, time, or datetime value by a given interval, and returns a date, time, or datetime value. Ex: INTNX(interval,start-from,number-of-increments,alignment)

intck will give the difference between two dates, you have the option to get the difference in days, months and year.

intnx will give the next or previous dates from the given date, for example if you wish to know the date after 10 days from the present date, you can get it by intnx, also if you want to get the 10 days earlier date from the present date yu can get it.

let me explain you the difference more clearly from the below code

/get the difference between two dates/

data have; 
input dob : ddmmyy8. today : ddmmyy8.; 
format dob today date9.; 
03051983 21122012 

data want; set have; /* in days/ age_days=intck('day',dob,today); / in months/ age_months=intck('month',dob,today); / in years*/ age_years=intck('year',dob,today); run;

/*date after 10 days*/ 

data next; 
set have; 
/*    after 10 days date*/ 
/* after 10 months date*/ 
/* after 10 years date*/ 
format next_days next_month next_year date9.;    

As you can see from the above code, intck can give the difference between two dates in days, months and years, however yrdif can give difference between two dates in only years. So intck is more flexible than yrdif.

   add comment

Your answer

Join with account you already have



Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!