Programming the statistical procedures from SAS

Applying weights to the data- NIS data

Regular Contributor
Posts: 180

Applying weights to the data- NIS data

Has anyone here worked anytime on NIS (National Inpatient database)?

I have been working on this data and I am almost ready with all the analyses which is mainly bivariate and multivariate. Now that I am ready with the results, I am wondering how I apply the weights to the data.

I am attaching a document in which they have explained it with a very simple example, So I am not yet sure how to apply it to my results.

and also the link where they have explained how to apply weights.

Here is the link for the tutorial "Producing National HCUP Estimates" useful in explaining and undertaking the process:

this is the link for tutorial in text form

Appreciate if someone could offer any suggestions, ideas



New Contributor
Posts: 3

Re: Applying weights to the data- NIS data

Posted in reply to Ashwini_uci


I'm going to be really broad because there's not a lot of detail in your post, so sorry if you know some of this already.

I believe the answer you're looking for is that your analyses should be performed on the weighted numbers if you want national or regional estimates. For instance, I'm currently working on the KID, which is weighted with the same commands.

proc surveymeans data=data1;

     var ASTHMA

     weight DISCWT;   

     cluster HOSPID;

     strata NIS_STRATUM;

     strata YEAR; /* Use this line if you're using a concatenated file of multiple NIS years */


will output the number of cases in the file, and some statistics. If you follow their instruction by putting a 1 in whatever variable you want to measure (for instance, all asthma cases) and 0 for other cases, the sum they give you in surveymeans will be the weighted frequency of the thing you want to measure.

Here's one way you could do the setup (assume the ICD9 code for asthma is 333.3):

data data1;

     set data0;

     if (DX1=3333 or DX2=3333 or [...] or DX25=3333) then ASTHMA=1;

     else ASTHMA=0;


If you get a sum of 1500, then the NIS estimate of asthma cases is 1500 nationally. You can tweak the if-then to get region results as well.

Now, to do your frequencies and crosstabs, we're going to want to use a proc called surveyfreq:

proc surveyfreq data1;


     weight DISCWT;

     cluster HOSPID;

     strata NIS_STRATUM;

     strata YEAR;

This will output a table for asthma vs. sex, asthma vs. race, and asthma vs. female vs. race (which will output as two tables: one controlling for ASTHMA=0 and one for ASTHMA=1). Weighted Frequency is the same as the sum from surveymeans.

For more complicated analyses, please see the SAS/STAT manual because I don't have a lot of experience with those.

Hope that helped.

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation