BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gieorgie
Quartz | Level 8

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

 

Gieorgie_0-1640075482958.png

 

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
Kurt_Bremser
Super User

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;

View solution in original post

4 REPLIES 4
Gieorgie
Quartz | Level 8
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
Kurt_Bremser
Super User

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;
Gieorgie
Quartz | Level 8
Thanks Kurt very much ! Happy xmass 🙂

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 421 views
  • 1 like
  • 2 in conversation