P.Escondido
P.Escondido

Reputation: 3553

How can I subtract two local macros containing variable names in Stata?

Imagine you have a list of variable names A,B,C,D,E saved in a local macro:

loc l1 "A B C D E"

You also have a different list of variable names A,C saved in a different macro:

loc l2 "A C"

How would you get the (set) difference of those, namely, a list of variable names B,D,E?

Upvotes: 1

Views: 3853

Answers (1)

Maarten Buis
Maarten Buis

Reputation: 2694

local l1  "A B C D E"
local l2 "A C"
local l3 : list l1 - l2
di "`l3'"

for more see: help extended fcn, and especially help macrolists.

Upvotes: 5

Related Questions