DATA Step, Macro, Functions and more

INTNX

Reply
Occasional Contributor
Posts: 13

INTNX

 

Hi All,

 

Can pls tell me what will be the output for the below logic

 

count (case when (reg_id in ('03') and 2009-04-30 BETWEEN intnx('month', "2009-07-30"d, -2, 'end')

 

AND intnx('month', "2009-07-30"d, -13, 'begin')) then 1 else . end) as cust_id

Respected Advisor
Posts: 3,010

Re: INTNX

Since we don't have your data, we can't possibly know what the output is.


Is your real question what is the code doing?

--
Paige Miller
Occasional Contributor
Posts: 13

Re: INTNX

Posted in reply to PaigeMiller

Hi

 

Can you pls tell me what the code actually do? or if you can put any dummy data and say the output for this?

 

I dont have sas to execute. so only not able to share the log or error.


,count (case when (reg_id in ('03') and REPORT_date BETWEEN intnx('month', "&VISION_date"d, -2, 'end')

AND intnx('month', "&VISION_date"d, -13, 'begin')) then 1 else . end) as cust_id

Super User
Posts: 10,238

Re: INTNX

[ Edited ]

Since 1975 (the result of the calculation 2009 - 4 -30) is a date sometime in the 1960's, you won't get any count out of this.

 

Hint: always post code as you run it, read the log and post it if it throws notes (ERROR, WARNING, NOTE) you do not expect. Also post example data against which the code can be tested.


@c4shiva wrote:

 

Hi All,

 

Can pls tell me what will be the output for the below logic

 

count (case when (reg_id in ('03') and 2009-04-30 BETWEEN intnx('month', "2009-07-30"d, -2, 'end')

 

AND intnx('month', "2009-07-30"d, -13, 'begin')) then 1 else . end) as cust_id


 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 13

Re: INTNX

Posted in reply to KurtBremser

Hi

 

The Actual code is below. I don't have sas to run the code and check for output. Am only having the sas code alone. Am reading this code in notepad and trying to get output and write the pseudo code. So only am not able to share the log or error message.

 

,count (case when (reg_id in ('03') and REPORT_date BETWEEN intnx('month', "&VISION_date"d, -2, 'end') AND intnx('month', "&VISION_date"d, -13, 'begin')) then 1 else . end) as cust_id

 

 

REPORT_date =2009-04-30

 

VISION_date=2009-07-30

 

Or 

can pls tell me what the code actually do? 

 

 

 

 

 

Super User
Posts: 10,238

Re: INTNX

It's part of an SQL select and delivers a count of all records where column reg_id is '03' and the date stored in column report_date falls into a range calculated from the macro variable vision_date. How intnx() works is found in the link provided by @Rick_SAS.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
SAS Super FREQ
Posts: 4,241

Re: INTNX

If your question is "what does the INTNX function do," then see the article "INTCK and INTNX: Two essential functions for computing intervals between dates in SAS."  The article provides links to the documentation and several excellent papers and books that describe INTNX and related date/time functions in SAS.

Super User
Posts: 13,534

Re: INTNX

[ Edited ]

Because there are so many different ways to indicate a date value that vary by nationality and to some extent personal preference SAS only accepts ONE date literals as either DATE9 or DATE7 appearance within quotes and the d appended: 'ddMONyyyy'd or 'ddMONyy'd.

So instead of 2009-04-30 you would want to use '30APR2009'd or  "30JUL2009"d.

 

Why is a standard approach to literals required? 1-2-2018 in some places would be 1 Feb and others 2 Jan. And can you tell me what date 2018185 is? LOTS of ways to indicate dates and some are pretty uncommon for some users. So SAS picked one so I don't have to guess what your date literal is (when it works).

Ask a Question
Discussion stats
  • 7 replies
  • 118 views
  • 0 likes
  • 5 in conversation