[MUSIC]
National Institutes of Health National Cancer Institute
Merging HINTS Data:
Assigning Weights and Creating a New, Merged Data Set
Welcome back!
In the previous video, we learned how to perform
data management on the two survey iterations
and how to assign values to the Survey variables.
Now, we’re going back to our data/set statements
to line up all of our weights.
Each HINTS iteration will contain one final sample weight,
which you’re going to use to apply to obtain
population-level point estimates.
Each iteration also has 50 replicate weights.
Replicate weights are used
to get your correct variance estimates,
which you’ll use for your statistical modeling.
So, this code here basically creates three arrays:
the first one contains the 50 replicate weights
from HINTS 4, Cycle 4;
the second code reads in the 50 replicate weights
from HINTS 5, Cycle 1;
and the third assigns 100 replicate weights,
nwgt1 to nwgt100, for the combined data.
The 100 replicate weights are created from concatenating
the 50 replicate weights from each iteration.
So, we’re saying if you are in the survey that equals 1
and that is the HINTS 4, Cycle 4, then basically
there is a do loop here, and it goes from 1 to 50.
This variable here, person_finwt0,
is the name of the final sample weight for each iteration.
We create a new variable called nwgt0
for the combined data set, which is equal to person_finwt0.
You will use nwgt0 as your final sample weight variable
after you merge the two iterations together.
This code here says that for the new weights 1 through 100,
replicate weight i becomes new weight i.
And we do that for the first 50.
So, if you are in Survey 1, in HINTS 4, Cycle 4,
the first 50 replicate weights will literally just be
the original replicate weights found in the data set.
And basically for 51 through 100, it says 50 plus i—
remember i goes from 1 to 50,
so 50 plus 1, 50 plus 2, 50 through 100—
so, 50 plus i will be the final sample weight
copied over from HINTS 4, Cycle 4.
Then for Survey 2, we do the same thing, but in reverse.
So, why do we do that?
We do that so when calculating variance estimates,
the replicate weights for each respondent
will accurately reflect their original values
per the variance estimation formula,
and the constant will ensure that replicate weights
not assigned in the original data set will drop out.
For more information on this,
check out the HINTS data users handbook from 2008.
Please note that,
if you plan to combine more than two iterations together,
the number of replicate weights should be
the number of iterations multiplied by 50.
Correctly assigning replicate weights
for the combined data set is very important
for accurate variance estimates.
You can use the logic we demonstrate here to create
new final sample weight and replicate weight variables.
Keep in mind that you should have one final sample weight
and 50xK replicate weights, where K is the number
of iterations you are merging together.
To summarize this, if you’re in Survey 1,
your first 50 weights will be the original replicate weights
you had in the data set.
The second 50 weights will be
the final sample weight copied over, so a constant.
For Survey 2, just the opposite.
The first 50 replicate weights will be a constant,
the final sample weight from HINTS 5, Cycle 1.
And 51 through 100 will be your original replicate weights
from the data set.
So, if we run this code, we will basically
create a new data set
that is called merge HINTS 4 Cycle 4_HINTS 5 Cycle 1.
And, of course, this new data set will be
the combination of these two temporary data files that we
created up here with the data/set statements.
So, if we do run that, then we end up with a data set
that combines respondents from the two iterations
and has one final sample weight and 100 replicate weights.
If we go to the SAS data view tab,
you can see the merged data file.
And I can verify that we have 6,962 total respondents
in our combined data set.
If we look back at our two original data sets,
we can confirm that the sum of respondents should be 6,962,
which confirms that all of the data are accounted for.
We can also confirm the weights that we created
with the do loop code.
We have nwgt 1 all the way up through nwgt 100.
Notice also that we have nwgt 0, which is that final
sample weight that’s lined up in one column.
We also created this new survey variable,
so you can see that all the respondents here
are in HINTS 4, Cycle 4,
and all the respondents here are in HINTS 5, Cycle 1.
That becomes a grouping variable to use like any other
grouping variable in your modeling, such as gender.
In this case, it distinguishes between the two iterations
of the HINTS survey.
So, now that we’ve set up the data set and verified
that it has the correct number of respondents
and that we aligned our weights correctly,
we’re ready to run statistical analyses.
Check out Video 4 to see that analysis in action.
U.S. Department of Health & Human Services
National Institutes of Health National Cancer Institute
cancer.gov
1-800-4-CANCER
Produced October 2018 118 00:05:32,599 --> 00:00:00,000 [MUSIC]