## intnx to decrement quarter year

Frequent Contributor
Posts: 83

# intnx to decrement quarter year

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
Posts: 3,852

## Re: intnx to decrement quarter year

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]
Frequent Contributor
Posts: 83

## Re: intnx to decrement quarter year

Thankyou.

Actually i need a function which is capable of reducing the qtr and year back say by a factor of n.
Super Contributor
Posts: 3,176

## Re: intnx to decrement quarter year

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.
Posts: 3,852

## Re: intnx to decrement quarter year

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]
Discussion stats
• 4 replies
• 416 views
• 0 likes
• 3 in conversation