I am receiving parameters in a format like
I would like to store the the constant (that is, the value in the parmvalue column for the row where the parmname column takes value "constant"). I can think of two alternatives, neither of which are very appealing:
(1) preserve-keep/drop-save-restore:
(2) select in mata
Both of these options are clearly atrocious. If there were some straightforward way to find and store the relevant row in a local, say myrow, then I could do
which would be ideal in terms of simplicity and readability of the code. Is there such a thing, or some other reasonable way of approaching this problem?
Code:
clear input str15 parmname float parmvalue "j=1" 1.111 "j=2" 2.111 "constant" 3.111 "j=1#t=1" 4.111 "j=1#t=2" 5.111 "j=2#t=1" 6.111 "j=2#t=2" 7.111 end
(1) preserve-keep/drop-save-restore:
Code:
preserve keep if parmname=="constant" global parm_constant `=parmvalue' restore
Code:
mata: st_global ("parm_constant", strofreal(select ( st_data (.,"parmvalue"),st_sdata (.,"parmname"):=="constant")) )
Code:
global parm_constant `=parmvalue[`myrow']'
Comment