Dear Listers,
Each ID has long rows for the ID and an indicator - complete_surgical. I want to change the indicator to 1 in row 1 and row 51 if first three rows of each ID has non missing in procd1_7. So complete_surgical in row 51 should be 1 as procd1_7 in row 51, 52 and 53 has at least one non missing value. Of course this is part of the whole data and there are so many personids.
clear
input float complete_surgical byte(procd1_7 procd8_36w) str12 subjid str21 personid
1 0 0 "N01REACT1001" "1"
1 0 0 "" "1"
1 1 0 "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
. . . "" "1"
1 . 0 "N01REACT1002" "2"
1 . 0 "" "2"
1 1 1 "" "2"
. . . "" "2"
. . . "" "2"
. . . "" "2"
. . . "" "2"
. . . "" "2"
end
Many thanks in advance.
Kind regards,
Kim
Related Posts with one of row is non missing then replace first row of each ID
Interpretation Confidence interval including zeroHi, I'm performing a Negative binomial regression (xtnbreg), however, I found that the confidence i…
"no observations r(2000)" error when using Wooldridge test for autocorrelation in panel data set Dear stata list, I have a question regarding the Wooldridge test for autocorrelation (command: 'xts…
Looping over pairIs it possible to loop over a pair rather than one each? For example, as a hypothetical code, I woul…
Panel regression with country fixed effect and panel-robust standard errorsDear Statalist Members: I have some questions about the panel regression with country fixed effect …
Extensive and Intensive margins à la Hummels and Klenow (2005)Dear Stata users, I am studying the effect of migration on trade and I would like to start on calcul…
Subscribe to:
Post Comments (Atom)
0 Response to one of row is non missing then replace first row of each ID
Post a Comment