BookmarkSubscribeRSS Feed
Lucas
Calcite | Level 5
Hi,
Does anyone can explain what is the bahaviour of INTNX function when 'interval' argument is an integer number?

data test1;
format date1-date6 date.;
date1=intnx("1",today(),0,"b");
date2=intnx("2",today(),0,"b");
date3=intnx("3",today(),0,"b");
date4=intnx("4",today(),0,"b");
date5=intnx("5",today(),0,"b");
date6=intnx("6",today(),0,"b");
run;

The results are unexpected for me 😕
8 REPLIES 8
Peter_C
Rhodochrosite | Level 12
Lucas

You are missing something.
Have you looked at the examples in the on line doc?
Lucas
Calcite | Level 5
Peter.C

Of course I have looked. It is always first thing I try to do 🙂
Unfortunately there is nothing about situation I have mentioned.
There is only description of intervals like 'Year', 'Month', 'Week'...
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Okay - please explain what you are attempting to accomplish with INTNX and what result would you like to see - show data values, please.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

using dates intnx site:sas.com
Peter_C
Rhodochrosite | Level 12
Lucas
pardon me for the inappropriateness of my response
I misjudged the objective of your posting
Your posting has served to inform us
as demonstrated by ArtC
That you can shift a default interval
interesting
peterC
art297
Opal | Level 21
Peter,

Santa Clause was concerned there for a moment.

Art
Peter_C
Rhodochrosite | Level 12
😉
LAP
Quartz | Level 8 LAP
Quartz | Level 8
I think you are misinterpreting what you can use as an interval. In the explantion of the intnx function there is a link that explains valid values.

The syntax explanation clearly states

interval
specifies the NAME of the basic interval type. For example, YEAR specifies yearly intervals.

For a complete list of the valid values for interval, see the Intervals Used with Date and Time Functions table in SAS Language Reference: Concepts.

I don't see '1','2' etc. listed in this table. Message was edited by: LAP
ArtC
Rhodochrosite | Level 12
Lucas,
Are you pointing out an oddity? Like: "why didn't I get an error for using an unspecified interval?".

I believe the default interval is DAY and that the numbers are being picked up as interval multipliers. Which shows us a bit about how the interval is parsed when multipliers and shift operators are included. Consider this variation of your code:
[pre]data test1;
format date1-date6 date.;
date1=intnx("1",today(),0,"b");
date2=intnx("2",today(),0,"b");
date3=intnx("3",today(),0,"b");
date4=intnx("4",today(),0,"b");
date5=intnx("5",today(),0,"b");
date6=intnx("6",today(),0,"b");
output;
date1=intnx("day1",today(),0,"b");
date2=intnx("day2",today(),0,"b");
date3=intnx("day3",today(),0,"b");
date4=intnx("day4",today(),0,"b");
date5=intnx("day5",today(),0,"b");
date6=intnx("day6",today(),0,"b");
output;
run;
proc print data=test1;
run;[/pre]

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 8 replies
  • 1025 views
  • 0 likes
  • 6 in conversation