proc tabulate: am i using correct weight statement?

Background: for my dataset I produce a contingency table with proc TABULATE of all case characteristics crossed with the type of clinic they attended (3-levels). In the contingency table I also have SAS calculate the percentage of cases using the denominator of the clinic-type level.

Problem: The problem is, when I calculate the percentage by hand using the printed SAS frequencies I get a slightly different percentage that what SAS calculates. For example, SAS says that males make up 52.5% (N=1205) of all non-STD clinic attendees (N=2326), but when I calculate that percentage I get 1205/2326= .518, 51.8%, (which is about 9.8% off). I am wondering if SAS is calculating the percentage of the unweighted clinic types denominator, but using the weighted characteristic frequency?

1) am I correctly weighting my dataset? I found information here: and it looks like instead of using "var wtcap" I should use the "weight wtcap" statement, but even when I do this I still get percentages that differ from the SAS contingency table compared to my hand-calculated values. Not to mention, when I use the "weight wtcap" statement the cell frequencies are much larger. Should I be using proc SURVEYFREQ?

2) does anyone know how to use the weighted value for the denominator of the percentage other than using the weight statement which I am using with the line " var wtcap" (or, if that statement is wrong, then "weight wtcap") when running proc TABULATE?

See my current code below:

options nodate nonumber;
proc tabulate data= MISSING ;
KEYLABEL N="Total cases" ALL="Total cases" PCTN="%" sum=" ";
var wtcap;
label wtcap="cases (weighted)";
class /*demographics*/ GENDER2 AGEGR2 RACE2B ATTND;
classlev /*demographics*/ GENDER2 AGEGR2 RACE2B ATTND;
TABLE ALL /*demographics*/ GENDER2 AGEGR2 RACE2B
(ATTND*(wtcap*f=4.2 pctn<ALL
/*demographics*/ GENDER2 AGEGR2 RACE2B>*f=4.1)) ALL;

Thanks for any advice!
Last edited: