Hello,
I am trying to fill in the same value for each missing variable within an id (pid in my dataex example below). So the variables ad1, ad2, etc. should all be the same value for each pid.
Looking at previous Stata forum posts, I feel like I should be able to use the code:
bysort pid(ad1):replace ad1=ad1[1] if missing(ad1)
Or the code:
bysort pid(ad10):replace ad10=ad10[1]
However, when I try these I am getting the error "coding operators not allowed."
I also tried to install xfill but the link doesn't work.
Any advice?
Thank you,
Sarah
I am trying to fill in the same value for each missing variable within an id (pid in my dataex example below). So the variables ad1, ad2, etc. should all be the same value for each pid.
Looking at previous Stata forum posts, I feel like I should be able to use the code:
bysort pid(ad1):replace ad1=ad1[1] if missing(ad1)
Or the code:
bysort pid(ad10):replace ad10=ad10[1]
However, when I try these I am getting the error "coding operators not allowed."
I also tried to install xfill but the link doesn't work.
Any advice?
Thank you,
Sarah
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long pid float(ad1 ad2 ad3 ad4 ad5 ad6 ad7 ad8 ad9 ad10) 1000006 0 . . . . . . . . . 1000006 . .2142857 . . . . . . . . 1000006 . . 1 . . . . . . . 1000006 . . . .5714286 . . . . . . 1000006 . . . . .071428575 . . . . . 1000006 . . . . . .9285714 . . . . 1000006 . . . . . . 1 . . . 1000006 . . . . . . . 1 . . 1000006 . . . . . . . . 1 . 1000006 . . . . . . . . . .2142857 1000006 . . . . . . . . . . 1000006 . . . . . . . . . . 1000006 . . . . . . . . . . 1000008 .07692308 . . . . . . . . . 1000008 . .4285714 . . . . . . . . 1000008 . . .2142857 . . . . . . . 1000008 . . . .2857143 . . . . . . 1000008 . . . . .3571429 . . . . . 1000008 . . . . . .2142857 . . . . 1000008 . . . . . . 0 . . . 1000008 . . . . . . . .071428575 . . 1000008 . . . . . . . . 0 . 1000008 . . . . . . . . . .14285715 1000008 . . . . . . . . . . 1000008 . . . . . . . . . . 1000008 . . . . . . . . . . 1000012 .7857143 . . . . . . . . . 1000012 . 1 . . . . . . . . 1000012 . . .14285715 . . . . . . . 1000012 . . . .7857143 . . . . . . 1000012 . . . . .4285714 . . . . . 1000012 . . . . . 0 . . . . 1000012 . . . . . . 0 . . . 1000012 . . . . . . . 0 . . 1000012 . . . . . . . . 0 . 1000012 . . . . . . . . . 0 1000012 . . . . . . . . . . 1000012 . . . . . . . . . . 1000012 . . . . . . . . . . 1000048 .4285714 . . . . . . . . . 1000048 . 0 . . . . . . . . 1000048 . . .5714286 . . . . . . . 1000048 . . . 0 . . . . . . 1000048 . . . . .071428575 . . . . . 1000048 . . . . . .5 . . . . 1000048 . . . . . . 0 . . . 1000063 0 . . . . . . . . . 1000063 . .6428571 . . . . . . . . 1000063 . . .8571429 . . . . . . . 1000063 . . . .8571429 . . . . . . 1000063 . . . . .8571429 . . . . . 1000063 . . . . . .6428571 . . . . 1000063 . . . . . . 1 . . . 1000063 . . . . . . . .53846157 . . 1000063 . . . . . . . . .4285714 . 1000063 . . . . . . . . . .5 1000063 . . . . . . . . . . 1000063 . . . . . . . . . . 1000070 .4285714 . . . . . . . . . 1000070 . .5 . . . . . . . . 1000070 . . .4285714 . . . . . . . 1000070 . . . 1 . . . . . . 1000070 . . . . .9285714 . . . . . 1000070 . . . . . .9285714 . . . . 1000070 . . . . . . .9285714 . . . 1000070 . . . . . . . .7142857 . . 1000070 . . . . . . . . .9285714 . 1000070 . . . . . . . . . .9285714 1000070 . . . . . . . . . . 1000070 . . . . . . . . . . 1000070 . . . . . . . . . . 1000081 0 . . . . . . . . . 1000081 . .2857143 . . . . . . . . 1000081 . . 0 . . . . . . . 1000081 . . . 0 . . . . . . 1000081 . . . . 0 . . . . . 1000081 . . . . . 0 . . . . 1000081 . . . . . . 0 . . . 1000081 . . . . . . . 0 . . 1000081 . . . . . . . . 0 . 1000089 0 . . . . . . . . . 1000089 . 0 . . . . . . . . 1000089 . . .2142857 . . . . . . . 1000089 . . . 0 . . . . . . 1000089 . . . . .2142857 . . . . . 1000089 . . . . . .071428575 . . . . 1000089 . . . . . . 1 . . . 1000089 . . . . . . . .6428571 . . 1000089 . . . . . . . . .9285714 . 1000089 . . . . . . . . . .6428571 1000089 . . . . . . . . . . 1000089 . . . . . . . . . . 1000089 . . . . . . . . . . 1000089 . . . . . . . . . . 1000098 0 . . . . . . . . . 1000098 . .2857143 . . . . . . . . 1000098 . . .9285714 . . . . . . . 1000098 . . . .7857143 . . . . . . 1000098 . . . . .9285714 . . . . . 1000098 . . . . . .9285714 . . . . end
Comment