Hi everyone,
I am currently working with panel data. Lets say I have four data sets, each containing the same questions.
I start by using the data of year 1 and want to merge year 2, keeping all variables. Preferably, I want all variables to have a prefix for their year.
On the first data set, I just used rename to add my prefix to each variable and change back the name of my key variable to its old name:
rename (* a*)
rename arespid respid
Now I have a problem when I merge the data for the next year. I only know how to change all variable names, but not how to only change those of the using data set.
Is there a way to add a prefix to all variables and exclude the key variable?
I already thought of renaming, saving, clearing, using, renaming saving etc. but I guess thats a pretty complicated way of reaching my goal.
Thank you all in advance.
Related Posts with Add common prefix to all variables (except key variable) when merging data
working of egen groupHello, I've data were I have for one reporting date several observations, but I only want keep the f…
generating an indexHi, I am trying to generate the index "z" in Stata, so that Z has the same value for all Xs and Ys. …
Reshape long (date; price_68372V; price_138056) Code: * Example generated by -dataex-. To install: ssc install dataex clear input float date doubl…
Excel files: Merge worksheets within Excel files and append Excel files with a loopDear Statalist, We have collected annual data on minorities in several countries for 25 years. Now …
margins in spatial panel data analysisHi, I have a problem using margins after the Spatial-AutoRegressive model, using xsmle. First I run…
Subscribe to:
Post Comments (Atom)
0 Response to Add common prefix to all variables (except key variable) when merging data
Post a Comment