Programming the statistical procedures from SAS

weights for ctable (classification table) in proc logistic; also suppressing scientific notation

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

weights for ctable (classification table) in proc logistic; also suppressing scientific notation

I am running proc logistic with observations weighted, as shown below.

title 'Logistic regression analysis of the dataset using backward elimination';

proc logistic data=RE_apids ;

class   RACE (ref='1') FEMALE (ref='0') / param=ref;

model nir(EVENT='1')= race sex

  / selection=backward

  expb /* For each parameter estimate, also display the odds ratio in the output */

  fast

  slentry=0.1  /* For a variable to be allow to enter the model,

              a significance level of 0.1 was required (SLENTRY=0.1) */

  slstay=0.05  /* For a variable to be allow to stay in the model,

              a significance level of 0.05 was required (SLSTAY=0.05) */

  details

  lackfit

  CTABLE PPROB=(0.05 TO 0.5 BY 0.05);

weight adjwgt;

run;

For my proc logistic output, I have requested a classification table.  However, there are two problems.

1) Some of the cells in the classification table show values in scientific notation and I need them to be displayed in non-scientific notation.  How can I do that?

2) The classification table is giving me unweighted statistics, but I need the counts displayed in the CTABLE to be weighted by the variable I provided (which is adjwgt).  How can I do that?  I have already specified weight adjwgt; (as you can see above) but that only affected the selection of variables for the logistic model.  It didn't affect how the CTABLE calculated the overall percentage of correct predictions, sensitivity, specificity, the false positive percentage or the false negative percentage.  The CTABLE is giving me all those percentages based on unweighted numbers of observations in the dataset.     , ation


Accepted Solutions
Solution
‎01-31-2013 04:49 PM
SAS Employee
Posts: 242

Re: weights for ctable (classification table) in proc logistic; also suppressing scientific notation

This note deals generally with using different formats in results -- it uses the example of changing precision, but the general idea of saving the data with ODS OUTPUT and printing with the desired formats applies generally.

http://support.sas.com/kb/37106

Note that if your weights are sampling weights, then only the procedures whose names start with SURVEY (such as SURVEYLOGISTIC) have the necessary variance estimators to provide a proper analysis.  The WEIGHT statement in PROC LOGISTIC is not appropriate for modeling survey data.  That being said, the OUTROC= option provides sensitivities and specificities.  You can use the ROCOPTIONS(WEIGHTED) option in the PROC LOGISTIC statement to have the weights multiply the counts as shown in the "Details: Receiver Operating Characteristic Curves: ROC Computations" section of the LOGISTIC documentation.

View solution in original post


All Replies
Valued Guide
Valued Guide
Posts: 684

Re: weights for ctable (classification table) in proc logistic; also suppressing scientific notation

I get different CTABLE results when I use WEIGHT versus when I do not use a weight. It is using the fitted logistic model to make the predictions, which depends on the weights. The procedure does not weight the actual observations, however, in the table; I don't think I would want to do that.

Occasional Contributor
Posts: 14

Re: weights for ctable (classification table) in proc logistic; also suppressing scientific notation

Yes, you will get different CTABLE results when you do not use the weight, because you will be creating an entirely different model with its own intercept, coefficients, goodness of fit, statistical significance, etc, and so the predicted probabilities shown in the CTABLE will also be different. 

It is important for the data shown in the CTABLE to reflect the predictions that were made by the model for the weighted dataset.

Valued Guide
Valued Guide
Posts: 684

Re: weights for ctable (classification table) in proc logistic; also suppressing scientific notation

Yes, I agree with you. That was the point I was trying to make (but probably not clearly). You should, and do, get different results with a weight versus no weight. I see no point in weighting the counts in the table.

By the way, many statisticians strongly dislike the use of stepwise variable selection procedures (including backward selection). You can find many posts on this website about this.

Super User
Posts: 5,255

Re: weights for ctable (classification table) in proc logistic; also suppressing scientific notation

Regarding the scientific notation, ODS lets you control that.  You could start by adding this statement just before the PROC LOGISTIC:

ODS TRACE ON;

That will show you the different pieces that ODS is generating.  You may want a solution that changes the template for one of those pieces, or my preference is to use ODS to capture one of the pieces as a SAS data set.  Run a PROC CONTENTS, perhaps a PROC PRINT if the piece is small enough.  That would give you enough information about what to print, what formats to change, etc.

That's the overview ... time is short and I'm not sure I can commit to following up.  But there are plenty of posters here who can answer questions if you have them.

Good luck.

Solution
‎01-31-2013 04:49 PM
SAS Employee
Posts: 242

Re: weights for ctable (classification table) in proc logistic; also suppressing scientific notation

This note deals generally with using different formats in results -- it uses the example of changing precision, but the general idea of saving the data with ODS OUTPUT and printing with the desired formats applies generally.

http://support.sas.com/kb/37106

Note that if your weights are sampling weights, then only the procedures whose names start with SURVEY (such as SURVEYLOGISTIC) have the necessary variance estimators to provide a proper analysis.  The WEIGHT statement in PROC LOGISTIC is not appropriate for modeling survey data.  That being said, the OUTROC= option provides sensitivities and specificities.  You can use the ROCOPTIONS(WEIGHTED) option in the PROC LOGISTIC statement to have the weights multiply the counts as shown in the "Details: Receiver Operating Characteristic Curves: ROC Computations" section of the LOGISTIC documentation.

🔒 This topic is solved and locked.

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

Discussion stats
  • 5 replies
  • 353 views
  • 1 like
  • 4 in conversation