简体   繁体   中英

SAS - Create an incremental table

I need to create an incremental table in SAS. This table contains the first day of month and the final month day until today (every month needs to execute).It seems like this

First day month Final month day
01/01/2019  31/01/2019
01/02/2019  28/02/2019
01/03/2019  31/03/2019
01/04/2019  30/04/2019
01/05/2019  31/05/2019
01/06/2019  30/06/2019
01/07/2019  31/07/2019
01/08/2019  31/08/2019
01/09/2019  30/09/2019
01/10/2019  31/10/2019
01/11/2019  30/11/2019
01/12/2019  31/12/2019
01/01/2020  31/01/2020
01/02/2020  29/02/2020
01/03/2020  31/03/2020
01/04/2020  30/04/2020
01/05/2020  31/05/2020
01/06/2020  30/06/2020
01/07/2020  31/07/2020
01/08/2020  31/08/2020
01/09/2020  30/09/2020
01/10/2020  31/10/2020

Thanks

Try this

data want;
   first = '01jan2019'd;
   do while (1);
      last = intnx('month', first, 0, 'e');
      if last > today() then leave;
      output;
      first = last + 1;
   end;
   format first last ddmmyy10.;
run;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM