BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zihdonv19
Obsidian | Level 7

Hi,

 

I'm confused about the answer of this question.

 

The question asks the retured date of TargetYear=intnx('year','20Jul18'd,3); and the answer is date value of 22281, which corresponds to January 1, 2021.

 

For me, i think the answer should be July 20, 2021. Could someone explain this question?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

There is another option to the function example not shown that provides an "alignment" value. It takes the values of Beginning, Middle, End or Same. The default if not provided is beginning.

 

Your expectation would be the result of

TargetYear=intnx('year','20Jul18'd,3, 'S');

Which will attempt to set the same day of the next interval, so if the interval is 'year' you get 20Jul2021. If the interval is 'month' you get 20Oct2018.

If you have an interval of 'week' and ask for an alignment of 'M' or 'Middle' you get what ever the appropriate Wednesday would be. End would the last day of an interval, last day of the year, month or week.

View solution in original post

4 REPLIES 4
ballardw
Super User

There is another option to the function example not shown that provides an "alignment" value. It takes the values of Beginning, Middle, End or Same. The default if not provided is beginning.

 

Your expectation would be the result of

TargetYear=intnx('year','20Jul18'd,3, 'S');

Which will attempt to set the same day of the next interval, so if the interval is 'year' you get 20Jul2021. If the interval is 'month' you get 20Oct2018.

If you have an interval of 'week' and ask for an alignment of 'M' or 'Middle' you get what ever the appropriate Wednesday would be. End would the last day of an interval, last day of the year, month or week.

zihdonv19
Obsidian | Level 7
Thanks for your reply!
smantha
Lapis Lazuli | Level 10

sas intox gives the beginning of the time period you asked always. If you ask for 156 weeks. It will calculate 156 weeks and return sunday of the week as the answer. So you have to be careful what you chose as your intent period i.e. year, week, day. The smaller the time period granularity you chose the lesser the error.

zihdonv19
Obsidian | Level 7
thanks for your reply!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 471 views
  • 0 likes
  • 3 in conversation