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