0
votes

I have a string variable

var1
x
y 
z

that I need to "duplicate" and append to give

var1 var2
x      x
x      y
x      z
--------
y      x
y      y
y      z
--------
z      x
z      y
z      z

where I added the horizontal lines to facilitate reading. Is such an expansion possible in Stata without loops? (I am not sure if "duplicate" is the right term.)

1

1 Answers

0
votes

Two commands:

gen var2 = var1
fillin var1 var2

See help fillin and http://www.stata-journal.com/sjpdf.html?articlenum=dm0011