## Weight variable in PROC TABULATE

Solved
Occasional Contributor
Posts: 9

# Weight variable in PROC TABULATE

Hello

In the below PROC TABULATE syntax am using sewwt as a weight variable which is a non-integer variable. But this variable has no effect on the output. Am not using any var statement here because i just need to  calculate the row percentages.

proc tabulate data= mylib.cab8 ;

where filter8;

format q08 q08a. q13 q13a. q30 q30a. q31b q31b. q97a q97aa. q98 q98a. q99 q99a. q78rr q78rr.;

class q08 q78rr q13 q30 q31b q97a q98 q99/ style=[just=center] style=[font_weight=bold] preloadfmt order=data;

table q08='Age' q78rr='Sex' q13 q30 q31b all='Total',(q97a='' q98='' q99='')*f=COMMA8.1*rowpctn='' N='No. of persons'*f=best8.0/rts=25  box='Districts' style=[font_face=arial];

weight sewwt;

run;

Q1) Why this  weight variable has no effect on class variables?

Q2) What is the other alternative method that I can use?

Accepted Solutions
Solution
‎08-25-2014 04:11 PM
Posts: 1,270

## Re: Weight variable in PROC TABULATE

Try this to see how it works?

table q08='Age' q78rr='Sex' q13 q30 q31b all='Total',(q97a='' q98='' q99='')*f=COMMA8.1*sewwt*(rowpctsum='' Sum='No. of persons'*f=best8.0)/rts=25  box='Districts' style=[font_face=arial];

All Replies
Posts: 1,270

## Re: Weight variable in PROC TABULATE

What is filter8 variable? Are you sure weight variable sewwt has values for those selected through filter8 variable?

Occasional Contributor
Posts: 9

## Re: Weight variable in PROC TABULATE

Filter8 is just a condition here e.g filter8= (q08>=15).

And m sure that sewwt has values for the selected filter.

Posts: 1,270

## Re: Weight variable in PROC TABULATE

Occasional Contributor
Posts: 9

## Re: Weight variable in PROC TABULATE

To use SUMWGT , I need to specify some variables in var statement, but as I have already told I don need var statement in my syntax. Am only using class(category) variables here.

Occasional Contributor
Posts: 9

## Re: Weight variable in PROC TABULATE

Is there any possible way that I can apply the weight on a complete dataset and then use that weighted dataset for further tabulation?

Posts: 1,270

## Re: Weight variable in PROC TABULATE

How about using sewwt as an analysis variable to get weighted n and percentages? Just use sewwt varible in var statement and calculate weighted sum and weighted n.

Occasional Contributor
Posts: 9

## Re: Weight variable in PROC TABULATE

U mean to say like this?

proc tabulate data= mylib.cab8 ;

where filter8;

format q08 q08a. q13 q13a. q30 q30a. q31b q31b. q97a q97aa. q98 q98a. q99 q99a. q78rr q78rr.;

class q08 q78rr q13 q30 q31b q97a q98 q99/ style=[just=center] style=[font_weight=bold] preloadfmt order=data;

var sewwt;

table q08='Age' q78rr='Sex' q13 q30 q31b all='Total',(q97a='' q98='' q99='')*f=COMMA8.1*rowpctn='' N='No. of persons'*f=best8.0/rts=25  box='Districts' style=[font_face=arial];

run;

Solution
‎08-25-2014 04:11 PM
Posts: 1,270

## Re: Weight variable in PROC TABULATE

Try this to see how it works?

table q08='Age' q78rr='Sex' q13 q30 q31b all='Total',(q97a='' q98='' q99='')*f=COMMA8.1*sewwt*(rowpctsum='' Sum='No. of persons'*f=best8.0)/rts=25  box='Districts' style=[font_face=arial];

Occasional Contributor
Posts: 9

## Re: Weight variable in PROC TABULATE

It is just calculating the rowpctsum values rather than rowpctn. So its not working.

Occasional Contributor
Posts: 9

## Re: Weight variable in PROC TABULATE

Hey

Actually you were right. I tried using  the sewwt variable in var statement and removed the weight statement  and also using  rowpctsum instead of rowpctn.