I am puzzled about how to do something that I am sure is simple. I have two lists: (a) a list of drugs and (b) a list of minimum doses of those drugs. I have data on patients who have been prescribed one of more of those drugs and I want to create a set of variables that indicate whether the prescription is at or above the minimum.
Here is the local macro for the list of drugs and the macro containing the list of minimum doses:
The roots_orig macro points to a list of total doses per day, e.g. amlo_total. I want to create a new variable, e.g. amlo_gcc if the value of amlo_total >= 5 and proceed similarly across the list of drugs.
If I were programming this "by hand" I would simply write:
etc
I realize that I can't do this with nested foreach loops, but I can't seem to figure out how to handle the two lists in parallel. It might be easiest to just brute force a solution, but I have a number of other instances to deal with.
Here is the local macro for the list of drugs and the macro containing the list of minimum doses:
Code:
local roots_orig amlo aten azil ben carv chlor fur hctz ind irb lis los neb nif nis spiro tel val meto_ir meto_la local orig_min 5 50 40 10 6.25 25 40 12.5 1.25 150 10 100 5 30 10 25 40 320 75 25
If I were programming this "by hand" I would simply write:
Code:
gen amlo_gcc = amlo_total >= 5 gen aten_gcc = aten_total >= 50
I realize that I can't do this with nested foreach loops, but I can't seem to figure out how to handle the two lists in parallel. It might be easiest to just brute force a solution, but I have a number of other instances to deal with.
Comment