Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!

PROC REPORT - SUMMUARIZE WITH WEIGHTED AVERAGE

Reply
Contributor
Posts: 62

PROC REPORT - SUMMUARIZE WITH WEIGHTED AVERAGE

Hi,

i have this proc report:

proc report nowd data=ATM_EXPO.TOTALE_EXPORT_RE_T_&TERM_YM ; 
COLUMN    
  
 PERIMETRO    
 CLUSTER     
 tipo_terminale_    
 N_TERM    
 N_prelievi_medi 
 Importo_prelievi_medio
 Delta_anno_imp_prel 
 
 ORDINE 

 
 Media_trim_LDS_prel    
 Delta_anno_prec_LDS_prel    
 N_TERM_VER 
 N_versamenti_medi   
 Importo_versamenti_medio  
 Delta_anno_imp_verS
 
 Media_trim_LDS_ver_as    
 Delta_anno_prec_ver_as    
 Media_trim_LDS_ver_co    
 Delta_anno_prec_ver_co    
;



DEFINE PERIMETRO /GROUP 'Perimetro';
DEFINE  ORDINE/  NOPRINT ORDER=DATA;
DEFINE CLUSTER  /GROUP ORDER=DATA 'Cluster';
DEFINE  tipo_terminale_  /GROUP ORDER=DATA 'Tipo terminale';

DEFINE  N_TERM /analysis SUM 'Numero ATM' ;
DEFINE N_prelievi_medi  / analysis mean 'Numero prelievi per ATM' ;
DEFINE Importo_prelievi_medio / analysis mean 'Imp.prel. per ATM' ; 
define Delta_anno_imp_prel / analysis mean 'Delta' style(column)={tagattr='format:###0.00%'};  

DEFINE Media_trim_LDS_prel / analysis mean 'LDS prelievo ultimo trimeste' style(column)={tagattr='format:###0.00%'};    
DEFINE  Delta_anno_prec_LDS_prel     / analysis mean 'Delta trimestre anno corr. vs prec.'  style(column)={tagattr='format:###0.00%'}; 
DEFINE N_TERM_VER /analysis SUM 'Numero ATM di versamento' ;  

DEFINE  N_versamenti_medi   / analysis mean 'Numero versamenti per ATM' ;
DEFINE Importo_versamenti_medio / analysis mean 'Imp. versato per ATM' ;  
DEFINE Delta_anno_imp_verS / analysis mean 'Delta' style(column)={tagattr='format:###0.00%'};  

DEFINE  Media_trim_LDS_ver_as  / analysis mean 'LDS ver.ass. ultimo trimestre' style(column)={tagattr='format:###0.00%'};     
DEFINE  Delta_anno_prec_ver_as / analysis mean 'Delta trimestre anno corr. vs prec.' style(column)={tagattr='format:###0.00%'};     
DEFINE  Media_trim_LDS_ver_co  / analysis mean 'LDS ver.cont. ultimo trimestre' style(column)={tagattr='format:###0.00%'};  
DEFINE  Delta_anno_prec_ver_co   / analysis mean 'Delta trimestre anno corr. vs prec.' style(column)={tagattr='format:###0.00%'};
 
 
break after  CLUSTER  / suppress summarize dol skip;
 
compute after CLUSTER;
tipo_terminale_ = "SubTotale" ;
if CLUSTER = "Totale Region"  then call define (_row_, 'style', 'style=[background=lightgreen]');
call define (_row_, 'style', 'style=[background=lightgray]');

endcomp;

compute cluster;
if CLUSTER = "Totale Region" then call define (_row_, 'style', 'style=[background=lightgreen]');
if CLUSTER = "ITALY"  then call define (_row_, 'style', 'style=[background=YELLOW]');
endcomp;

run;

How can i calculate the weighted average with variable “NUMERO ATM’ (1.107,2.092,537,1.796) ??

PROC REPORT.JPG

Thank's so much

Respected Advisor
Posts: 3,294

Re: PROC REPORT - SUMMUARIZE WITH WEIGHTED AVERAGE

Use PROC SUMMARY, compute the weighted average there (and all other needed statistics), then create the PROC REPORT code to display it.

--
Paige Miller
SAS Super FREQ
Posts: 831

Re: PROC REPORT - SUMMUARIZE WITH WEIGHTED AVERAGE

Proc REPORT has support for the WEIGHT statement. See sample code below. Maybe with this you can get what you need.

 

proc means data=sashelp.cars sum mean maxdec=0;
  class type;
  var invoice;
  weight Cylinders;
run;

proc report data=sashelp.cars;
  column type invoice=invsum invoice=invavg;
  define type / group;
  define invsum / analysis sum format=comma12. "invsum";
  define invavg / analysis mean format=comma12. "invavg";
  weight Cylinders;
run;
Ask a Question
Discussion stats
  • 2 replies
  • 145 views
  • 0 likes
  • 3 in conversation