BookmarkSubscribeRSS Feed
SAS_NUBI2015
Calcite | Level 5

Hello together,

I've a question based on SAS date and time interval about selection of quarters via pattern:

I try to select the the quarters from year 2014 until current quarter (20152). The output is some thing like that:

20142

20143

20144

20151

20152

As I understood the SAS function 'YYQ' the return value is like YYQ or YYYYQ. Because the saved format of quarters is YYYYQ in my table is, I tried the following syntaxs without success:

Attempt 1: WHERE T1.V_quarter_date >= yyq(year(date()))-1,qtr(date()));

Attempt 2: WHERE T1.V_quarter_date >= (yyq(year(date))-1,intnx('Q',today(),0,'S'));

The another possibility was in my opinion as follows:

WHERE T1.V_quarter_date >= (input( ((year(date))-1) || intnx('Q',today(),0,'S')),best5.);     //converting char to num

What is wronge in my syntax?

Thank you.

3 REPLIES 3
Ksharp
Super User

You can not use yyq() in that way if V_quarter_date  is a DATE type variable.

WHERE T1.V_quarter_date between '01JAN2014'd and '28FEB2015'd  ;

SAS_NUBI2015
Calcite | Level 5

Hello together,

the right solution ist:

where 

T1.V_quarter_date >= (input( put((intnx('Q',today(),-1,'beginning')),yyqn5.),5.);

Thanx again.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 992 views
  • 6 likes
  • 3 in conversation