0
votes

I have a table of frequencies that I'm feeding into a Proc Tabulate step. The data come with a weight variable, and I want to include the weighted results in the generated table. Whether I use the weight variable in the VAR or the WEIGHT option, it has no effect on the output table. I've also tried using the weight variable in the TABLE statements for the analysis variables, but again, no effect.


PROC FORMAT; PICTURE PCTF (ROUND) OTHER='009.9%'; RUN;
ODS HTML PATH="%SYSFUNC(GETOPTION(WORK) )" STYLE=JOURNAL1A;

PROC TABULATE DATA = CHSS2017_s1 f=10.2 S=[just=c cellwidth=75]; 

CLASS AGE SEX Q21;

CLASSLEV AGE      / style=[font_weight=medium];
CLASSLEV SEX      / style=[font_weight=medium];
CLASSLEV Q21;

WEIGHT REGIONWT ;
*VAR REGIONWT ;

TABLE ALL     = 'Greater Cincinnati Residents' * (ROWPCTN=' '*f=PCTF.)
      AGE     = 'Age'            * (ROWPCTN='   '*f=PCTF.)
      SEX                        * (ROWPCTN='   '*f=PCTF.)
      , Q21;

RUN;

The expected result should be a proc tabulate output with values that reflect the weight variable, 'REGIONWT'

1
Weight with a VAR statement should work. If that isn't working, please post the code that demonstrates that. Preferably use a SASHELP data set so we can run/replicate your code. As is, we cannot test your code or output because we don't have the sample data. SASHELP.HEART would be appropriate here.Reeza
@Richard were you able to use WEIGHT in your PROC TABULATE code? I am facing the same issue (WEIGHT has no affect on my output) in my code, please let me know if you have some information on how to use WEIGHT in PROC TABULATE.PriyamK
Did you try FREQ per @Quentin answer? Otherwise, create a new question if you are looking for a way to have a weighted N statistic. Be sure to show some sample data, your code and the output that you get and example of what you want.Richard

1 Answers

2
votes

From my reading of the docs, in PROC TABULATE the WEIGHT statement specifies weights for analysis variables, i.e. variables listed on a VAR statement.

You don't have any analysis variables, you only have class variables.

You might want to look into the FREQ statement as it will impact counts and %, but note that it will treat all the weights as integers.