Is there an efficient way of moving a column or row vector with strings into a list so as to use with macrolists in Stata? Since the vectors can be thousands of values, I would rather not loop over each element.
I have a two string matrices (vectors, actually) in Mata containing values of a numeric variable, including extended missing values stored as .a .b. etc. I can move these to Stata matrices.
I ultimately would like a macro list with the elements of A that are not in B. Were they in list form, I could easily get this with : list A - B.
(A couple of almost solutions in Mata: this post gives a way to get the common elements from real matrices; and -indexnot- only works 1 character elements.) I'm a Mata newbie, so a Stata solution would be easier for me to understand, but I'm open to Mata if there is an efficient solution.
Thanks,
Carole
I have a two string matrices (vectors, actually) in Mata containing values of a numeric variable, including extended missing values stored as .a .b. etc. I can move these to Stata matrices.
I ultimately would like a macro list with the elements of A that are not in B. Were they in list form, I could easily get this with : list A - B.
(A couple of almost solutions in Mata: this post gives a way to get the common elements from real matrices; and -indexnot- only works 1 character elements.) I'm a Mata newbie, so a Stata solution would be easier for me to understand, but I'm open to Mata if there is an efficient solution.
Code:
mata: A=(1, 2, 3, 10, .a, .b, .c) mata: B=(1, 2, .a) mata: st_matrix("A", A) mata: st_matrix("B", B) mat list A mat list B
Thanks,
Carole
Comment