Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sampling weights in STATA

    Hi all,

    I am working with a French micro-level database. I merge two different data sets (but they originate from the same source and the data collection methodology and procedure are the same). For some years (after 2005 in dataset 1 ) the sampling weights are already included in the data. But since I merge two datasets, some firms do not have weights before the year 2005 (the merged data set 2 ).


    The variables (probability or sampling weights) "weight_rev" AND "weight_emp" are already included but they are missing for years of the dataset2. I need to generate weights and replace those missings.

    For the "weight_rev" I use the variable "rev" which is the revenue.
    For the "weight_emp" I use the variable "emplo" which is the labour number range/class. For this one, I need to generate annual inverse probability weights based on "exp1_inds_4" and "emplo".


    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int year byte(id exp1_code_inds imp1_code_inds) str1 headq_link float(weight_rev rev emplo weight_emp exp1_inds_4)
    2000 1 50 30 "a"    . 1500 2    . 5010
    2000 1 40 40 "b"    . 1500 2    . 4010
    2000 1 40 20 "b"    . 1500 2    . 4010
    2000 1 40 30 "b"    . 1500 2    . 4010
    2000 1 50 20 "a"    . 1500 2    . 5010
    2000 1 50 40 "a"    . 1500 2    . 5010
    2003 1 50 40 "a"    .  570 5    . 5010
    2003 1 50 30 "a"    .  570 5    . 5010
    2003 1 50 20 "a"    .  570 5    . 5010
    2003 1 40 30 "b"    .  570 5    . 4010
    2003 1 40 40 "b"    .  570 5    . 4010
    2003 1 40 20 "b"    .  570 5    . 4010
    2004 1 40 30 "b"    .  490 2    . 4010
    2004 1 50 30 "a"    .  490 2    . 5010
    2004 1 50 20 "a"    .  490 2    . 5010
    2004 1 40 40 "b"    .  490 2    . 4010
    2004 1 40 20 "b"    .  490 2    . 4010
    2004 1 50 40 "a"    .  490 2    . 5010
    2011 1 40 20 "b" 1.66  900 2  .83 4010
    2011 1 50 30 "a" 1.66  900 2  .83 5010
    2011 1 50 20 "a" 1.66  900 2  .83 5010
    2011 1 50 40 "a" 1.66  900 2  .83 5010
    2011 1 40 40 "b" 1.66  900 2  .83 4010
    2011 1 40 30 "b" 1.66  900 2  .83 4010
    2012 1 50 30 "a"  1.9  980 2  .95 5010
    2012 1 50 40 "a"  1.9  980 2  .95 5010
    2012 1 50 20 "a"  1.9  980 2  .95 5010
    2012 1 40 20 "b"  1.9  980 2  .95 4010
    2012 1 40 30 "b"  1.9  980 2  .95 4010
    2012 1 40 40 "b"  1.9  980 2  .95 4010
    2013 1 40 40 "b"  1.5  550 2  .75 4010
    2013 1 50 20 "a"  1.5  550 2  .75 5010
    2013 1 40 30 "b"  1.5  550 2  .75 4010
    2013 1 40 20 "b"  1.5  550 2  .75 4010
    2013 1 50 30 "a"  1.5  550 2  .75 5010
    2013 1 50 40 "a"  1.5  550 2  .75 5010
    2000 2 30 30 "a"    .  550 4    . 3010
    2000 2 40 30 "b"    .  550 4    . 4010
    2000 2 40 40 "b"    .  550 4    . 4010
    2000 2 30 20 "a"    .  550 4    . 3010
    2000 2 30 40 "a"    .  550 4    . 3010
    2000 2 40 20 "b"    .  550 4    . 4010
    2003 2 40 30 "b"    .  550 1    . 4010
    2003 2 40 40 "b"    .  550 1    . 4010
    2003 2 30 20 "a"    .  550 1    . 3010
    2003 2 30 30 "a"    .  550 1    . 3010
    2003 2 30 40 "a"    .  550 1    . 3010
    2003 2 40 20 "b"    .  550 1    . 4010
    2004 2 40 40 "b"    .  980 1    . 4010
    2004 2 30 30 "a"    .  980 1    . 3010
    2004 2 40 30 "b"    .  980 1    . 4010
    2004 2 30 20 "a"    .  980 1    . 3010
    2004 2 40 20 "b"    .  980 1    . 4010
    2004 2 30 40 "a"    .  980 1    . 3010
    2011 2 40 30 "b" 1.33  900 1 .665 4010
    2011 2 30 40 "a" 1.33  900 1 .665 3010
    2011 2 30 30 "a" 1.33  900 1 .665 3010
    2011 2 30 20 "a" 1.33  900 1 .665 3010
    2011 2 40 20 "b" 1.33  900 1 .665 4010
    2011 2 40 40 "b" 1.33  900 1 .665 4010
    2012 2 40 20 "b" 1.88  490 1  .94 4010
    2012 2 40 40 "b" 1.88  490 1  .94 4010
    2012 2 40 30 "b" 1.88  490 1  .94 4010
    2012 2 30 40 "a" 1.88  490 1  .94 3010
    2012 2 30 20 "a" 1.88  490 1  .94 3010
    2012 2 30 30 "a" 1.88  490 1  .94 3010
    2013 2 40 30 "b"  1.4  570 1   .7 4010
    2013 2 30 40 "a"  1.4  570 1   .7 3010
    2013 2 30 30 "a"  1.4  570 1   .7 3010
    2013 2 40 20 "b"  1.4  570 1   .7 4010
    2013 2 40 40 "b"  1.4  570 1   .7 4010
    2013 2 30 20 "a"  1.4  570 1   .7 3010
    end
    format %ty year
    ------------------ copy up to and including the previous line ------------------


    Is this possible or does it make sense? Thanks
Working...
X