Hello,
In the data extract below, cell_x is a variable with value labels. I want to create local macros (one for each observation in the data) such that the name of the local macros are the value labels of cell_x and the value of the local macros are the value of the unemp variable corresponding to that observation.
E.g., I would like local macros as follows but I want to do this in a loop.
Any advice on how I can achieve this?
Thanks!
In the data extract below, cell_x is a variable with value labels. I want to create local macros (one for each observation in the data) such that the name of the local macros are the value labels of cell_x and the value of the local macros are the value of the unemp variable corresponding to that observation.
E.g., I would like local macros as follows but I want to do this in a loop.
Code:
local x_e1-x_n1-x_l1 = .0664063 local x_e1-x_n1-x_l2 = .1428571 local x_e1-x_n2-x_l1 = .04 local x_e1-x_n2-x_l2 = .1794872 local x_e1-x_n2-x_l3 = .125 local x_e2-x_n1-x_l1 = .031746 . . .
Thanks!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(cell_x unemp) double count 1 .06640625 256 2 .14285715 14 4 .04 25 5 .1794872 39 6 .125 16 10 .031746034 630 11 .033898305 177 13 .0591716 169 14 .024904214 522 15 .015384615 195 17 .03517588 199 18 .028688524 488 19 0 14 22 .14285715 7 23 0 64 24 0 53 26 .0754717 53 27 .025787966 349 end label values cell_x cell_x label def cell_x 1 "x_e1-x_n1-x_l1", modify label def cell_x 2 "x_e1-x_n1-x_l2", modify label def cell_x 4 "x_e1-x_n2-x_l1", modify label def cell_x 5 "x_e1-x_n2-x_l2", modify label def cell_x 6 "x_e1-x_n2-x_l3", modify label def cell_x 10 "x_e2-x_n1-x_l1", modify label def cell_x 11 "x_e2-x_n1-x_l2", modify label def cell_x 13 "x_e2-x_n2-x_l1", modify label def cell_x 14 "x_e2-x_n2-x_l2", modify label def cell_x 15 "x_e2-x_n2-x_l3", modify label def cell_x 17 "x_e2-x_n3-x_l2", modify label def cell_x 18 "x_e2-x_n3-x_l3", modify label def cell_x 19 "x_e3-x_n1-x_l1", modify label def cell_x 22 "x_e3-x_n2-x_l1", modify label def cell_x 23 "x_e3-x_n2-x_l2", modify label def cell_x 24 "x_e3-x_n2-x_l3", modify label def cell_x 26 "x_e3-x_n3-x_l2", modify label def cell_x 27 "x_e3-x_n3-x_l3", modify

Comment