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]

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 1515 views
  • 0 likes
  • 3 in conversation