I have around 1600 variables with suffixes coming from the variable id. I was wondering whether you could help me with revising the code below so that the new order of the variables is the same as rows? For instance, con_1504 should come first after id, and con_1503 second, and so on
My code may be nowhere close to the correct version but here it is:
foreach var in con_1-con_2482 {
forval j = 1/1657 {
local this = string(id[`j'])
local that = substr(`var', 5, .)
}
}
Thank you in advance for any suggestions and Merry Christmas to all!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int id float(con_4 con_6 con_8 con_16 con_17 con_19 con_23 con_24 con_26) 1504 0 0 0 0 0 0 0 0 0 1503 0 0 0 0 0 0 0 0 0 1625 0 0 0 0 0 0 0 0 0 1502 0 0 0 0 0 0 0 0 0 1626 0 0 0 0 0 0 0 0 0 1627 0 0 0 0 0 0 0 0 0 1761 0 0 0 0 0 0 0 0 0 1760 0 0 0 0 0 0 0 0 0 1762 0 0 0 0 0 0 0 0 0 1759 0 0 0 0 0 0 0 0 0 end
0 Response to order variables using foreach
Post a Comment