Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: AW: copydesc with a twist??


From   "Lachenbruch, Peter" <Peter.Lachenbruch@oregonstate.edu>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: AW: copydesc with a twist??
Date   Fri, 7 May 2010 09:56:24 -0700

I had to do something like that recently.  I made a do file from the data menu and then used a text editor to replace the variable names in the label define command.  If you have 200 different variables, then I suspect you may have 200 find-replace lines...

Tony

Peter A. Lachenbruch
Department of Public Health
Oregon State University
Corvallis, OR 97330
Phone: 541-737-3832
FAX: 541-737-4001


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Ploutz-Snyder, Robert (JSC-SK)[USRA]
Sent: Friday, May 07, 2010 9:30 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: AW: copydesc with a twist??

Indeed, copydesc is an oldie.  But clonevar clones the entire variable, including the contents.  So using clonevar here would copy over the variable labels "as-is," without the modification that I desire, and it would also copy over the CONTENTS of the oldvar to the newvar.

I'm just looking to copy the label from a list of oldvars to a list of newvars, but also want to add some text to those labels.



-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
Sent: Friday, May 07, 2010 11:24 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: AW: copydesc with a twist??


<> 

-ssc d copydesc- looks like old code to me, although it may well serve a
useful purpose, and only got like 35 hits last month. It is # 66 on Nick`s
hit list (-ssc hot, auth(cox) n(66)-), but no discussion related to it has
been recorded in the archive since the end of 2003. That could be because
official -clonevar- can do its job more efficiently. Since Nick is the
author of the official command as well, there might be a connection there...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Ploutz-Snyder,
Robert (JSC-SK)[USRA]
Gesendet: Freitag, 7. Mai 2010 17:37
An: statalist@hsphsun2.harvard.edu
Betreff: st: copydesc with a twist??

I'm looking for a quick way to copy variable labels from a set of variables
(ex. x1-x100) to a set of new variables (ex. a1-a100), but I need a minor
modification of the new labels.

Nicholas' copydesc command comes very close, as I can imbed it in a loop as:

For J in num 1/100: copydesk xJ aJ

But here's the rub.  In this case all of the aJ variables are a
transformation of xJ.  I'd like the transformation to become part of the
variable label too.

Here are two variables as a specific example:

              storage  display     value
variable name   type   format      label      variable label
----------------------------------------------------------------
x2              float  %8.0g                  HeadGy
a2              float  %9.0g                  abs(x2)



I would LIKE the label for a2 to be "abs(HeadGy)"  not "abs(x2)".  I have a
zillion of these, so I don't want to hand-code them all...

Anyone know of an ado already written to do this?  Or a way to use
copydesc??

Much appreciated,
Rob




*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index