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
@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.
Let's check the documentation.
Increments a date, time, or datetime value by a given time interval, and returns a date, time, or datetime value.
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
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
I want no of days between 1JAN1960 to today
@BrahmanandaRao wrote:
I want no of days between 1JAN1960 to today
You already got the answer to that.
I 100% guarantee if you read this paper you will have the answer.
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/...
@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.
data want;
number_of_days_since_01JAN1960=today();
run;
@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".
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 .
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.