Monday, December 1, 2008

SAS TIPS - TIP 8 - How to Create Weighted Calculations in Proc Tabulate

Proc tabulate needs a special attention to get weighted calculation. We need to create a special variable which assigns value 1 to all the records that need to be weighted on. In this example, the varible FLAG captures that. Also, we need to use ROWPCTSUM, rather than ROWPCTN (if you are interested in row percentages to be calculated.

PROC TABULATE DATA=A.Datain_with_wgts MISSING;
VAR flag ;WEIGHT R_wgt;
Title "People who postponed their purchases";
CLASS segments postpone quarter_year;
WHERE segements=Seg1;
TABLE (quater_Year ALL) , (Postpone ALL)*flag*(sum*F=6.0 ROWPCTSUM*F=6.2) /rts=10;
FORMAT segments segments. ;
RUN;

Created in association with Rathy. C

No comments: