Closed ideabucket closed 2 years ago
Using tempvar
is definitely a good idea but I just wasn't sure what's the best way to get the variable name. I will try out the PR either tomorrow or on Thursday.
I think the clear()
method is still needed, otherwise the temporary variable will show up the next time *%browse
is called.
I've tweaked the SelVar class to use Stata's
tempvar
command to name the variables. This has a couple of advantages:tempvar
s itself, which eliminates the need to explicitly drop themtempvar
s are non-colliding with any existing variable nametempvar
does not mark the dataset as dirtySince
tempvar
s are syntactic sugar for a local macro, I use sfi to fetch the value they resolve to in order to populateSelVar.varname
rather than using a unique variable name on the python side of things.tempvar
itself has no problem being supplied the same string again and again.I also made a minor change to the invocation of
.replace
on the selection condition so it only replaces the first instance of "if
", just in case there's a variable in the varlist that happens to end in those characters.