Comparing elements of two different local macros in Stata -


i have local macro called peer_list contains 280 distinct elements, of strings.

i have local macro called used_list contains subset of elements contained in local peer_list.

for each element in peer_list test whether element in local used_list. if element exists in used_list discard it, else execute set of conditions.

i have tried use following code hasn't worked:

foreach peer in local peer_list {     if `:list peer in local used_list' {         * commands wish execute     }     else {         * commands wish execute     } } 

but hasn't worked. appreciate advice on alternative ways of accomplishing this.

you don't in sense code "hasn't worked" , don't provide reproducible example. nevertheless appear working along right lines.

 local beasts frog toad newt unicorn griffin   local real frog toad newt    foreach b of local beasts {       if `: list b in real' {           di "`b' real"       }      else di "`b' fabulous"   }    frog real  toad real  newt real  unicorn fabulous  griffin fabulous 

a common bug similar code define , use local macros in different locales cannot see each other.

a more obvious bug need keyword of not in. have legal, not want. compare

foreach b in local beasts {     di "`b'" }  local beasts 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -