BookmarkSubscribeRSS Feed
c4shiva
Calcite | Level 5

 

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

7 REPLIES 7
PaigeMiller
Diamond | Level 26

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
c4shiva
Calcite | Level 5

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

Kurt_Bremser
Super User

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


 

c4shiva
Calcite | Level 5

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? 

 

 

 

 

 

Kurt_Bremser
Super User

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.

Rick_SAS
SAS Super FREQ

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.

ballardw
Super User

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).

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 1030 views
  • 0 likes
  • 5 in conversation