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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: appending several files with different variable names


From   Yogesh Uppal <stata.list.queries@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: appending several files with different variable names
Date   Thu, 1 Mar 2012 22:01:23 -0500

Dear Statalisters,

I am appending multiple files each having over 100 variables, with
same variables having different names in some files. Some of these
variables have common strings in some files, but some others do not.
Since the number of files and variables is large, I do not want to
manually identify the variables that are same and give them some
common name. I was wondering if there is a code that already exists to
take care of issues like this.

What I was leaning towards is creating a local macro for each file and
use the command findname to look for some variable like var* and
create a r(varlist) of such variables. And then run another loop over
each file to rename each variable in r(varlist) to a specified name.

I was hoping this method would rename variables that have common
string var* (The problem I am facing here is that if some file does
not have the variable name identified by var*, my loop gives me an
error message).

Is this a right way to go about the problem? If not, could you please
suggest something better?

Thanks in advance!!!

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