Weight variable in PROC TABULATE

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

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
Trusted Advisor
Posts: 1,228

Re: Weight variable in PROC TABULATE

Posted in reply to TamannaGarg

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];

View solution in original post


All Replies
Trusted Advisor
Posts: 1,228

Re: Weight variable in PROC TABULATE

Posted in reply to TamannaGarg

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.

Trusted Advisor
Posts: 1,228

Re: Weight variable in PROC TABULATE

Posted in reply to TamannaGarg

Try putting SUMWGT instead of N in your table statement.

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

Posted in reply to TamannaGarg

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

Trusted Advisor
Posts: 1,228

Re: Weight variable in PROC TABULATE

Posted in reply to TamannaGarg

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
Trusted Advisor
Posts: 1,228

Re: Weight variable in PROC TABULATE

Posted in reply to TamannaGarg

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. Smiley Sad

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.

Thanks for your great help. Smiley Happy

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 431 views
  • 0 likes
  • 2 in conversation