Hi everyone. My SAS version is 9.4 and I have a dataset with 128967 observations, for each obs i have a date variable (dd/mm/yyyy) and 12 months of amounts (IMPO_1 -- IMPO_12). Here is a subset of my dataset: Oss DATA_DEC IMPO_1 IMPO_2 IMPO_3 IMPO_4 IMPO_5 IMPO_6 IMPO_7 IMPO_8 IMPO_9 IMPO_10 IMPO_11 IMPO_12 1 15/01/2018 549,78 547,07 544,71 542,36 539,84 537,32 534,8 532,28 530,75 529,45 527,86 . 2 25/05/2009 3.707,41 3.701,80 3.695,14 3.689,64 3.719,15 3.748,20 3.742,56 3.737,02 3.725,50 3.742,90 3.731,60 3.726,50 3 10/07/2009 307,2 306,4 301,5 310,5 312,23 309,45 305,12 301,23 307,25 289,56 286,25 215,9 4 15/04/2014 53,35 53,06 51,07 51,35 57,35 55,01 51,26 . . . . . 5 05/03/2009 121,16 119,48 114 100,89 85,82 76,43 82,31 76,71 76,25 74,69 75,14 73,12 For each observation I need to calculate the average of a variable number of 'IMPO_', this number of 'IMPO_' depends on month(DATA_DEC). For example: - for the first obs the MONTH(DATA_DEC)=1 so AVERAGE=MEAN(IMPO_1); - for the second obs the MONTH(DATA_DEC)=5 so AVERAGE=MEAN(OF IMPO_1 -- IMPO_5); - for the third obs the MONTH(DATA_DEC)=7 so AVERAGE=MEAN(OF IMPO_1 -- IMPO_7); .... and so on for each of 128967 observations. My wanted dataset needs to be like: Oss DATA_DEC IMPO_1 IMPO_2 IMPO_3 IMPO_4 IMPO_5 IMPO_6 IMPO_7 IMPO_8 IMPO_9 IMPO_10 IMPO_11 IMPO_12 AVERAGE 1 15/01/2018 549,78 547,07 544,71 542,36 539,84 537,32 534,8 532,28 530,75 529,45 527,86 . 549,78 2 25/05/2009 3.707,41 3.701,80 3.695,14 3.689,64 3.719,15 3.748,20 3.742,56 3.737,02 3.725,50 3.742,90 3.731,60 3.726,50 3.702,63 3 10/07/2009 307,2 306,4 301,5 310,5 312,23 309,45 305,12 301,23 307,25 289,56 286,25 215,9 307,49 4 15/04/2014 53,35 53,06 51,07 51,35 57,35 55,01 51,26 . . . . . 52,21 5 05/03/2009 121,16 119,48 114 100,89 85,82 76,43 82,31 76,71 76,25 74,69 75,14 73,12 118,21 How can i do this? I've tried creating a macro variable for each row, which holds the value of the month such as &month1, &month2... then referencing it in to the MEAN(OF IMPO_1 -- IMPO_&&&month&n) but for 128967 rows this is madness. Could someone help me please!!! Thank you!
... View more