Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: -copydesc- or -clonevar- that behaves reasonably for factor variables
From
Ryan Turner <[email protected]>
To
[email protected]
Subject
st: -copydesc- or -clonevar- that behaves reasonably for factor variables
Date
Thu, 13 Mar 2014 11:00:43 -0400
Dear Statalist,
I am trying to standardize my regressors, but because N differ somewhat significantly across models, I must standardize for each model. I previously wrote a hackish program to create and standardize tempvar copies of model variables, but as this did not support factor variables I also maintained all my factor variables as real variables in the data set (-gen s_var1 = s.var1-, -gen i_dum1 = i.dum1-). This has gotten too tedious, and I am trying to update my hackish program to support factor variables.
I have tried -fvrevar- with some success, except that as far as I can tell there is no way to retain factor variables' identity (label) in the output (output shows tempvar names __00000N and not a label describing the variables those tempvars were copied from). Unless I can retain variable identity (I have a lot of factor variables, and I am producing directly to LaTeX output tables with -eststo- and -esttab-), fvrevar is all but useless to me. Non-prototyping use cases of -fvrevar- are appreciated.
I have some hope with fvexpand, which allows me to explicitly describe each variable (including levels of an indicator, e.g. i(0).dum1). In essence I am reimplementing fvrevar (as I understand it) to maintain the variable label. I used Nick Cox's -copydesc- in the old version of my program, but of course this does not support factor variables.
I recognize it does not make sense to copy/clone a factor variable. I want a function that simply does what Stata's factor-variable-supporting regression functions do: generate appropriate labels for factor variables. For example, the output of -regress s.y s.x- will contain "S.y" and "S.x". So for example, -copydesc s.var s_var- would copy "Var Label" to s_var as "S.Var Label". Of course I don't think upgrading old, faithful -copydesc- (to support factor variables) is the goal here, but you get the idea.
Does such a function exist? Specifically, I want to copy the description of a variable, or clone it to a tempvar, and have it act sensibly when 'variable' is a factor variable (e.g., output "S.variable")? Any thoughts are appreciated. I can't imagine this task is so uncommon (strictly speaking, it should not so hard, but it certainly taxes my merely moderate Stata programming ability).
Sincerely,
Ryan
--
Ryan J. Turner, M.S. <rjturner cmu edu>
Engineering and Public Policy
Carnegie Mellon University
+1-412-304-5014 (C) | +1-484-483-3244 (GV)
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/