BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
data  dsn;
res=intnx('day','1jan1960'd,today());
format date date9.;
proc print;
run;

Here I want to know days between from 1JAN1960 to today 

intnx or intck which one 

12 REPLIES 12
PaigeMiller
Diamond | Level 26

@BrahmanandaRao wrote:
data  dsn;
res=intnx('day','1jan1960'd,today());
format date date9.;
proc print;
run;

Here I want to know days between from 1JAN1960 to today 

intnx or intck which one 


Simple! Try INTNX and if that doesn't give you the answer you want, try INTCK. (Or look it up in the SAS documentation)


Side issue: TODAY() gives you the number of days since 01JAN1960, no need to compute it via some other function.

--
Paige Miller
Reeza
Super User

Let's check the documentation.

 

INTNX Function

Increments a date, time, or datetime value by a given time interval, and returns a date, time, or datetime value.

 

INTCK Function

Returns the number of interval boundaries of a given kind that lie between two dates, times, or datetime values.

 

And the documentation is available in multiple languages.

 


@BrahmanandaRao wrote:
data  dsn;
res=intnx('day','1jan1960'd,today());
format date date9.;
proc print;
run;

Here I want to know days between from 1JAN1960 to today 

intnx or intck which one 


 

SASJedi
Ammonite | Level 13

Try this:

data  _null_;
   Today=today();
   /* Use INTNX to produce a date value incremented from a start date */
   TargetDate=intnx('day',Today,30);
   /* Use INTCK to count the number of intervals between two dates */
   DaysBetween=intck('day',Today,TargetDate);
   format T: mmddyy10.;
   file print;
   put Today= TargetDate= DaysBetween=;
run;

Results:

Today=06/18/2021 TargetDate=07/18/2021 DaysBetween=30  
Check out my Jedi SAS Tricks for SAS Users
BrahmanandaRao
Lapis Lazuli | Level 10

I want no of days between 1JAN1960 to today 

BrahmanandaRao
Lapis Lazuli | Level 10
I did not get answer
Kurt_Bremser
Super User

@BrahmanandaRao wrote:
I did not get answer

Learn to read.

Quote from PaigeMiller's post in this thread :

Side issue: TODAY() gives you the number of days since 01JAN1960, no need to compute it via some other function.

BrahmanandaRao
Lapis Lazuli | Level 10
Any one correct my code i did not get idea
PaigeMiller
Diamond | Level 26
data want;
     number_of_days_since_01JAN1960=today();
run;
--
Paige Miller
ballardw
Super User

@BrahmanandaRao wrote:
Any one correct my code i did not get idea

Show the log of the code you ran that "did not get idea".

Sajid01
Meteorite | Level 14

Hello @BrahmanandaRao 
You want to know number of days since January 1,1960.
Any SAS date is number of days since January 1,1960. If no output format is specified than SAS prints or stores dates since January 1,1960. Look at this example below. No special function needed

data _null_;
days_since01JAN1960=today();
put days_since01JAN1960=;
run;
/*Log output will be like this*/
1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         data _null_;
 74         days_since01JAN1960=today();
 75         put days_since01JAN1960=;
 76         run;
 
 days_since01JAN1960=22449

Hope you have your answer .

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 12 replies
  • 2673 views
  • 0 likes
  • 7 in conversation