Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: FW: Assigning labels of 1 file into another file?


From   "Steichen, Thomas J." <SteichT@rjrt.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: FW: Assigning labels of 1 file into another file?
Date   Wed, 12 Sep 2007 14:16:33 -0400

Probably a quicker way to label the variables is a variation on Sven's suggestion:

Run the following in file01 to construct a list of label commands on the screen ...

  foreach var of varlist _all {
    di "label `var' " `"""' "`: var label `var''" `"""'
  }

Copy the list of commands, paste it in a do file and run it in file02.

-----------------------------------
Thomas J. Steichen
steicht@rjrt.com
-----------------------------------
 
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Spiess, Sven Oliver
Sent: Wednesday, September 12, 2007 1:43 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: FW: Assigning labels of 1 file into another file?

Hi Ziad,

In case you actually want to label variables not their values, I would probably
try
to work with (two) loops.
 
In the first data set you could use,
	foreach var of varlist _all {
		local `var'label : variable label `var'
	}

then add a command to open your new file and run something like,
	foreach var of varlist _all {
		label `var' `"``var'label'"'
	}


Nevertheless, this would only work if your variables are named identically.
If you want to do that in separate do files use global macros instead. Also
I'm not sure if that will work out with the quotes in the second loop but it's
worth a shot.


I hope this can lead into the right direction.

Best
Sven-Oliver

 
> > -----Original Message-----
> > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> > statalist@hsphsun2.harvard.edu] On Behalf Of Ziad El-Khatib
> > Sent: Wednesday, September 12, 2007 1:02 PM
> > To: statalist@hsphsun2.harvard.edu
> > Subject: st: Assigning labels of 1 file into another file?
> >
> > Dear STATAlister
> > I did lose records of a STATA file and now repeating the work again,
> > to transfer the original file from Excel into STATA.
> > To avoid re-labeling the variables again, is it possible to move the
> > assigned labels from file01 into file02?
> >
> > Thank you and best regards
> > ziad
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/support/faqs/res/findit.html
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any
attachment(s), contains information that may be confidential,
protected by the attorney-client or other legal privileges, and/or
proprietary non-public information. If you are not an intended
recipient of this message or an authorized assistant to an intended
recipient, please notify the sender by replying to this message and
then delete it from your system. Use, dissemination, distribution,
or reproduction of this message and/or any of its attachments (if
any) by unintended recipients is not authorized and may be
unlawful.   

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index