Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Conserving variables labels while reshaping long a dataset.


From   "Steven Stillman (LMPG)" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Conserving variables labels while reshaping long a dataset.
Date   Fri, 31 Jan 2003 12:49:51 +1300

Below is a snippet of code which does what I believe you are asking about.
It uses the pre-reshape variable names from one round of variables to label
the post reshape variables.

Steve

-------- begin code -------
qui for var h9site h9census h9famid h9intday h9intmon h9intyer h9fmansw
h9nfmemo: global lX : variable label X; 
qui reshape long @site @census @famid @intday @intmon @intyer @fmansw
@nfmemo, i(houseid) j(round h5 h6 h7 h8 h9) string;

capture program drop labmove;
program define labmove;
syntax varlist, Pre(string);
foreach var of local varlist {;
la var `var' "${l`pre'`var'}";
};
end;

labmove site census famid intday intmon intyer fmansw nfmemo, pre(h9); 

-------- end code --------

> -----Original Message-----
> From:	[email protected] [SMTP:[email protected]]
> Sent:	Friday, January 31, 2003 9:51 AM
> To:	[email protected]
> Subject:	st: Conserving variables labels while reshaping long a
> dataset.
> 
> Dear Stata Users,
> 
> How to teel Stata to conserve the labels of variables while reshaping a
> dataset?
> 
> Best regards.
> 
> 
> 
> 
> *
> *   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/

The information contained in this document is intended only for the
 addressee and is not necessarily the views nor the official 
communication of the Department of Labour.  All final/official papers 
which are sent from the Department will be sent by non-electronic
means, on appropriate letterhead, signed by authorised personnel.
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index