Quartz | Level 8

## Aggregate to show results for the current year only

I have a table where I compare the results week to week.

I have aggregations of old dates using these functions.

```%let date_old=%sysfunc(intnx(year,%sysfunc(Today()),-1,s));
%put &=date_old;
proc format;
value vintf low-&date_old = 'OLD' other=[yymmd7.];
run;
/*agregujemy wyniki do daty vintf jako old*/
proc summary data=tablea_new nway;
class policy_vintage;
format policy_vintage vintf.;
var AKTYWNE WYGASLE;
output out=newtabe sum=;```

And I would like to do exactly the same, only to aggregate the dates to show the yearly range, i.e. 2021-01-2022-01. Or the current year 2021-01-2021-12. Is the following sample okay? What's the best way to do this?

```%let date_future=%sysfunc(intnx(year,%sysfunc(Today()),+12,s));
%put &=date_future;
proc format;
value vintfutr +&date_future= 'FUTURE' other=[yymmd7.];
run;
```
1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: Aggregate to show results for the current year only

Try this:

``````%let date_old=%sysfunc(intnx(year,%sysfunc(Today()),-1,s));
%let date_future=%sysfunc(intnx(year,%sysfunc(Today()),+1,s));
proc format;
value vintf
low-&date_old = 'OLD'
&date_future-high = 'FUTURE'
other=[yymmd7.]
;
run;``````
4 REPLIES 4
Super User

## Re: Aggregate to show results for the current year only

How many (and which) formatted values do you expect for your CLASS variable in the end?

Quartz | Level 8

## Re: Aggregate to show results for the current year only

I don't know if I understood you correctly. I would like aggregated OLD, i.e. all until the date of the current year as it is then each month in the current year, and then aggregation of FUTURE from the end of the year to the last date
Super User

## Re: Aggregate to show results for the current year only

Try this:

``````%let date_old=%sysfunc(intnx(year,%sysfunc(Today()),-1,s));
%let date_future=%sysfunc(intnx(year,%sysfunc(Today()),+1,s));
proc format;
value vintf
low-&date_old = 'OLD'
&date_future-high = 'FUTURE'
other=[yymmd7.]
;
run;``````
Quartz | Level 8

## Re: Aggregate to show results for the current year only

Thanks Kurt very much ! Happy xmass 🙂
Discussion stats
• 4 replies
• 422 views
• 1 like
• 2 in conversation