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
Cox regression hazard ratio interpretation----------------------- Code: * Example generated by -dataex-. For more info, type help dataex clea…
How to standardize Stata variables format before using -append- ?I have around 40 files that I would like to append together. However, two variables named a12 and a1…
Reshape wide with missing observationsHello, I am trying to reshape wide the dataset below. Basically i would like the months (January th…
calculation odd ratio for interaction terms using LincomI am doing logistic regression to look at several predictors for a certain outcome. I checked the in…
Can I define the cell contents of a table (or matrix)?New here, new to Stata (v17) I'm trying to create a table to later be exported to Excel. I would li…
Subscribe to:
Post Comments (Atom)
0 Response to one of row is non missing then replace first row of each ID
Post a Comment