DATA Step, Macro, Functions and more

How to add quarters in SAS?

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

How to add quarters in SAS?

Hello all together,

 

I am working with time quarters and I do need to add or substract quarters from an indexquarter.

Is there any way to do this in SAS?

 

My data contains an ID and an index date. With this index date I can define the year and the quarter of that index date.

Using the function yyq I can define the quarter of the index year as sas date value.

 

Now I would like to add two quarters to the index quarter. (E.g. two quarters of follow-up of a patient)

 

My Programm Looks like:

 

data two;

set one;

year_index=year(indexdate);

quarter_index_help=qtr(indexdate);

quarter_index=yyq(year_index,quarter_index_help); /* SAS date value with quarter and year */

 

future_index=quarter_index+2; /* That's what I want to do, add two quarters */

run;

 

Thanks for help

sasstats


Accepted Solutions
Solution
2 weeks ago
Frequent Contributor
Posts: 142

Re: How to add quarters in SAS?

try:
future_index=put(intnx('qtr',quarter_index,2),2.);

View solution in original post


All Replies
Solution
2 weeks ago
Frequent Contributor
Posts: 142

Re: How to add quarters in SAS?

try:
future_index=put(intnx('qtr',quarter_index,2),2.);
New Contributor
Posts: 2

Re: How to add quarters in SAS?

Hello,

 

thanks a lot!

 

In my datastep your syntax worked in the following way:

future_index=intnx('qtr',quarter_index,2);

format future_index yyq.;

 

But then it did what I wanted.

 

sasstats

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 73 views
  • 1 like
  • 2 in conversation