Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: appending several files with different variable names

From   Yogesh Uppal <[email protected]>
To   [email protected]
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!!!

*   For searches and help try:

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