Bookmark and Share

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]

Re: st: -copydesc- or -clonevar- that behaves reasonably for factor variables


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: -copydesc- or -clonevar- that behaves reasonably for factor variables
Date   Thu, 13 Mar 2014 15:58:16 +0000

Picking up on your title first as much as anything:

-copydesc- (SSC) long predates factor variables and in any case is
essentially obsolete given -clonevar- (official). (You didn't say
otherwise, but just to make it clear.)

program def copydesc
*! NJC 1.2.1 8 August 2000
* NJC 1.2.0 9 May 2000
* NJC 1.1.0 2 February 2000
* NJC 1.0.0 29 October 1999
        version 6.0

I don't get a very clear idea of what you are trying to do, but the
code of -clonevar- is a give-away. What it does is just fire up other
bits of Stata and most are documented under -help extended fcn-.

Nick
[email protected]


On 13 March 2014 15:00, Ryan Turner <[email protected]> wrote:
> 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).

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index