Hi all,
Is there any way to programmatically recover previous executed command ? Any local, creturn ?
thks,
Is there any way to programmatically recover previous executed command ? Any local, creturn ?
thks,
program define getcmdline, properties(prefix) rclass set prefix getcmdline gettoken first 0 : 0, parse(": ") `0' return add return local cmdline `0' end
capture program drop nota program define nota, rclass version 17.0 gettoken prefix command : 0, parse(":") if ustrregexm(`"`command'"', "\{([^{}]+?)\}") == 1 { local var = ustrregexs(1) } local clean0 = ustrregexrf("`command'", "\{", "") local clean = ustrregexrf("`clean0'", "\}", "") `clean' notes `var': `clean' end
. webuse auto (1978 automobile data) . nota: gen {price2} = price ^2 . nota: gen {price3} = price ^3 . nota: keep in 1/10 * many , many line of codes and days later, * one can retrieve the rational behind the variables, with a simple: . notes _dta: 1. From Consumer Reports with permission 2. keep in 1/10 price2: 1. gen price2 = price ^2 price3: 1. gen price3 = price ^3
. notes price2 price2: 1. gen price2 = price ^2
Comment