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
Help with rangestat calculating moving average results in all missing valuesHello I am trying to calculate the rolling average of the past 36 months (periods) and when I run th…
Merge datasets based on a range of a variableHi Statalist, This is my first post but I have found this forum invaluable in the past. Hopefully …
Fixed effects (individual and time), interacting FEs, and Time TrendsHi everyone! I have panel data of the form: Country Continent Year agprod drought ABW LAC 1972…
How do I keep the lowest numeric value for a variable on an annual basis over time?I have a focused question. I am working in long format. One of my variables is called “new_diff_days…
Mixed effect modelHi Stata experts, I have a longitudinal dataset with outcome recorded at 8 timepoints and exposure …
Subscribe to:
Post Comments (Atom)
0 Response to Add common prefix to all variables (except key variable) when merging data
Post a Comment