BookmarkSubscribeRSS Feed
tommy81
Obsidian | Level 7
Hi,

Does anyone know any function like intnx to increment or decrement quarteryear

if sysdate is 19oct2010 -- quarter year would be Q4 2010

I need

Q4 2010
Q3 2010
Q2 2010
Q1 2010
Q4 2009

Thankx
4 REPLIES 4
data_null__
Jade | Level 19
I think you just need to FORMAT the date.

[pre]
proc format;
picture QYYYY(default=9) other='Q%q %Y' (datatype=date);
run;

data _null_;
d = '19oct2010'd;
put d=yyq. d=Qyyyy.;
run;
[/pre]
tommy81
Obsidian | Level 7
Thankyou.

Actually i need a function which is capable of reducing the qtr and year back say by a factor of n.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The OP original post asked for a way to display a date as a quarter-year.

Otherwise, consider the INTNX function and QTR (argument #1). Check the SAS Language Dictionary DOC discussion on INTNX for details.

Scott Barry
SBBWorks, Inc.
data_null__
Jade | Level 19
INTNX?

[pre]
870 data _null_;
871 d = '19oct2010'd;
872 do o = -4 to 4;
873 q = intnx('QTR',d,o);
874 put q=date9. q=yyq.;
875 end;
876 run;

q=01OCT2009 q=2009Q4
q=01JAN2010 q=2010Q1
q=01APR2010 q=2010Q2
q=01JUL2010 q=2010Q3
q=01OCT2010 q=2010Q4
q=01JAN2011 q=2011Q1
q=01APR2011 q=2011Q2
q=01JUL2011 q=2011Q3
q=01OCT2011 q=2011Q4
[/pre]

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2004 views
  • 0 likes
  • 3 in conversation