Hello,
I am currently working with data about initial operations and subsequent readmissions which are recorded as separate observations. The index procedures and subsequent readmissions are identified by a variable "nod_visitlink" which tracks all observations about a particular patient. I have a variable "procname" which stores information regarding the type of operation that was received at index admission. I would like to add this data to all instances of patient admissions, i.e. subsequent readmissions which at this point only has missing values.
gen index_procname = ""
by nrd_visitlink, sort: gen pid = _n
gen procnamedummy = 0
replace procnamedummy = 1 if procname == "bpdds"
replace procnamedummy = 2 if procname == "roux"
replace procnamedummy = 3 if procname == "sleeve"
forvalues i=1/ ?? {
generate include = 1 if pid != `i' & procname != ""
by(nrd_visitlink): gen work = procnamedummy
replace index_procname = work if pid == `i'
drop include work
}
This is what I have so far but does not seem to be working. Anybody have any experience with anything similar? Thank you.
0 Response to Help manipulating data groups
Post a Comment