Announcement

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

  • Dropping certain observations of a variable in a specified range

    I want to drop only certain observations of l_growth for each naic that are between 1997Q1 and 2009Q3 ( so between ts 148 and 197) yet keep other values of l_growth for each naic in the range of ts values 198-210. This is done for the first naic yet I want the same for all other naic values.
    I have a range of other variables of which I want to keep the values of in all periods/all ts.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double naic float year double(ts l wage) float(lnl l_growth)
    311111 1997 148 19.329999923706055 789.5714111328125  2.961658         .
    311111 1997 149 19.320999145507813 745.7142944335938 2.9611926         .
    311111 1997 150 19.489999771118164 765.2857055664063 2.9699016         .
    311111 1997 151 19.672666549682617 801.2857055664063   2.97923         .
    311111 2001 164 19.290000915527344               963  2.959587         .
    311111 2001 165 19.306665420532227               869 2.9604504         .
    311111 2001 166  19.30699920654297               941 2.9604676         .
    311111 2001 167 19.410999298095703              1731   2.96584         .
    311111 2002 168 18.031333923339844               923  2.892111         .
    311111 2002 169  17.89900016784668               920  2.884745         .
    311111 2002 170 17.991334915161133               988   2.88989         .
    311111 2002 171 18.222000122070313               995 2.9026296         .
    311111 2003 172  17.95333480834961              1126  2.887776         .
    311111 2003 173 18.000333786010742               941 2.8903904         .
    311111 2003 174 17.992666244506836               956  2.889964         .
    311111 2003 175 18.002334594726563              1045 2.8905015         .
    311111 2004 176  17.69933319091797              1036  2.873527         .
    311111 2004 177  17.59000015258789               925 2.8673306         .
    311111 2004 178 17.657665252685547               986   2.87117         .
    311111 2004 179  17.56999969482422              1038  2.866193         .
    311111 2005 180 17.893665313720703              1044  2.884447         .
    311111 2005 181  17.94499969482422               946 2.8873115         .
    311111 2005 182  17.93899917602539              1002  2.886977         .
    311111 2005 183 18.209665298461914              1050 2.9019525         .
    311111 2006 184  18.33966636657715              1288  2.909066         .
    311111 2006 185 18.463666915893555              1001  2.915805         .
    311111 2006 186 18.743999481201172               981 2.9308736         .
    311111 2006 187   18.8613338470459              1073  2.937114         .
    311111 2007 188  18.56533432006836              1154  2.921296         .
    311111 2007 189 18.441665649414063               987 2.9146125         .
    311111 2007 190 18.736000061035156               978  2.930447         .
    311111 2007 191 19.071334838867188              1106 2.9481864         .
    311111 2008 192 18.977333068847656              1192  2.943245         .
    311111 2008 193 18.920000076293945              1012 2.9402196         .
    311111 2008 194  18.89433479309082               996  2.938862         .
    311111 2008 195  18.94499969482422              1160   2.94154         .
    311111 2009 196 19.645666122436523              1277  2.977857         .
    311111 2009 197 19.806333541870117              1042  2.986002         .
    311111 2009 198 19.895999908447266              1022  2.990519 .02886057
    311111 2009 199 20.117000579833984              1187  3.001565 .04037261
    311111 2010 200 20.121999740600586              1161  3.001814 .03191209
    311111 2010 201 20.454666137695313              1144  3.018211 .03898096
    311111 2010 202 20.538665771484375              1070  3.022309 .06542182
    311111 2010 203 20.645334243774414              1176 3.0274894 .06005383
    311111 2011 204 20.581666946411133              1281  3.024401 .06386399
    311111 2011 205 20.526334762573242              1102  3.021709 .07907844
    311111 2011 206 20.444334030151367              1102  3.017706 .04785538
    311111 2011 207  20.64266586303711              1184   3.02736 .06188107
    311111 2012 208 21.030000686645508              1443   3.04595 .03557539
    311111 2012 209 21.009666442871094              1077  3.044983 .07675862
    311111 2012 210  21.57699966430664              1121  3.071628  .0964384
    311119 1997 148  36.12666702270508 469.1666564941406 3.5870314   .611995
    311119 1997 149  36.03233337402344            474.75 3.5844166  .6192467
    311119 1997 150  35.87900161743164 473.5833435058594  3.580152  .6450727
    311119 1997 151 35.802669525146484               577 3.5780225  .6184356
    311119 1998 152  35.25699996948242               505  3.562664  .6022136
    311119 1998 153 35.147666931152344            546.75  3.559558  .5990906
    311119 1998 154  35.37166976928711            547.75  3.565911  .6000714
    311119 1998 155   35.2946662902832            563.75  3.563732  .6716208
    311119 1999 156 35.012332916259766  629.076904296875    3.5557  .6709554
    311119 1999 157 35.249332427978516 552.1538696289063 3.5624466  .6725564
    311119 1999 158  35.25299835205078               577 3.5625505  .6599209
    311119 1999 159  35.36600112915039 646.6923217773438  3.565751  .6779749
    311119 2000 160  34.41033172607422 684.8461303710938  3.538357  .6479664
    311119 2000 161  34.75199890136719 598.1538696289063  3.548237  .6582727
    311119 2000 162  34.74066925048828 546.3076782226563  3.547911  .6574094
    311119 2000 163  34.36899948120117 696.1538696289063  3.537155  .6636279
    311119 2001 164   33.9913330078125               693 3.5261056  .6587751
    311119 2001 165  33.94900131225586               673 3.5248594  .6536894
    311119 2001 166  33.83266830444336               699  3.521427  .6552341
    311119 2001 167  33.39033126831055               737 3.5082664  .6238196
    311119 2002 168   32.8736686706543               725  3.492672  .6053605
    311119 2002 169   33.0629997253418               700  3.498415  .6114378
    311119 2002 170  32.67166519165039               714  3.486508  .5845556
    311119 2002 171  32.72200012207031               742 3.4880476  .5789814
    311119 2003 172 31.927000045776367               745  3.463452 .54764724
    311119 2003 173 31.743000030517578               705  3.457672  .5267985
    311119 2003 174 31.352333068847656               767  3.445289 .50817466
    311119 2003 175 31.140666961669922               779 3.4385145 .51721835
    311119 2004 176 31.832666397094727               742  3.460493 .54588056
    311119 2004 177 31.476999282836914               732  3.449257  .5188103
    311119 2004 178 31.314334869384766               759  3.444076  .4958897
    311119 2004 179 31.217666625976563               843  3.440984  .4977391
    311119 2005 180   30.5049991607666               752 3.4178905  .4776709
    311119 2005 181 30.557334899902344               768  3.419605  .4807427
    311119 2005 182  30.54666519165039               779 3.4192555  .4777155
    311119 2005 183 30.645334243774414               829   3.42248  .4446235
    311119 2006 184 30.569000244140625               790 3.4199865  .4339848
    311119 2006 185 30.676334381103516               796 3.4234915  .4329727
    311119 2006 186 30.516000747680664               771  3.418251  .4166861
    311119 2006 187 30.665666580200195               838 3.4231436    .42133
    311119 2007 188 31.040000915527344               802  3.435277  .4170656
    311119 2007 189  31.49566650390625               819   3.44985  .4275408
    311119 2007 190 31.513999938964844               779  3.450432  .4229424
    311119 2007 191 31.836666107177734               876  3.460619   .436218
    311119 2008 192  32.09866714477539               829 3.4688146  .4471059
    311119 2008 193  32.03266525268555               809  3.466756  .4490504
    311119 2008 194  31.94099998474121               848 3.4638906 .43653035
    311119 2008 195 31.758333206176758               951  3.458155  .4122052
    311119 2009 196 31.666000366210938               844 3.4552436  .4102609
    end
    thanks!

  • #2
    it is not at all clear what you mean by "drop only certain observations of l_growth"? do you mean drop those observations or do you mean change l_growth to missing in those observations or ...?
    here are a command for the latter meaning:
    Code:
    replace l_growth=. if inrange(ts,148,197)

    Comment

    Working...
    X