Desktop productivity for business analysts and programmers

Compare rows and sum

Reply
New User
Posts: 1

Compare rows and sum

Hi,

  I'm trying to solve a question in SAS Guide with "Retains"  but I can't rich the result I expect.

I attach you an example:

the first one is the original information and the 2nd one is the result I need to obtain.

   

I need 2 rows for any change of "TARIFA_ATR" for each ID (CUPS).

If the "TARIFA_ATR" change in the same month I need to sum the "CONSUMO_EA_YYYYMM" and putting the sum in the line of the last"TARIFA_ATR"

Thank you

Regards

Alessandra


 

Ej1 - Datos originarios


 

 

CUPS


 

 

TARIFA_ATR


 

 

CONSUMO_EA_201412


 

 

CONSUMO_EA_201411


 

 

CONSUMO_EA_201410


 

 

CONSUMO_EA_201409


 

 

CONSUMO_EA_201408


 

 

ES0021000013252388LS


 

 
  1. 2.0A
 

 

4,000000


 

 

3,000000


 

 

2,000000


 

 

0,000000


 

 

0,000000


 

 

ES0021000013252388LS


 

 
  1. 3.0A
 

 

0,000000


 

 

0,000000


 

 

1,000000


 

 

3,000000


 

 

3,000000


 

 

Ej2 - Resultado esperado


 

 

CUPS


 

 

TARIFA_ATR


 

 

CONSUMO_EA_201412


 

 

CONSUMO_EA_201411


 

 

CONSUMO_EA_201410


 

 

CONSUMO_EA_201409


 

 

CONSUMO_EA_201408


 

 

ES0021000013252388LS


 

 
  1. 2.0A
 

 

4,000000


 

 

3,000000


 

 

3,000000


 

 

0,000000


 

 

0,000000


 

 

ES0021000013252388LS


 

 
  1. 3.0A
 

 

0,000000


 

 

0,000000


 

 

0,000000


 

 

3,000000


 

 

3,000000


 
Ask a Question
Discussion stats
  • 0 replies
  • 234 views
  • 0 likes
  • 1 in conversation