Dear members,
I have a panel dataset and I would like to append another dataset to it which has the same set of identifiers and years. It is essentially a duplicate which has different values for the variables. The reason I want to do this is so that I can create xtline graphs to compare the two sets of data for the variable x where the IDs are on the y axis and year on the x axis. For example, two red lines for ID 1, two green lines for ID 2.
I have figured out how to plot separate graphs and put it side by side for comparison. But to enable better comparison, I would like to combine the datasets and plot them together on the same graph. Any help on how to combine the two datasets and obtain a single graph comparing them would be greatly appreciated.
Example data
I want to turn this:
clear
input int(id year x_1)
1 1992 160
1 1993 120
1 1994 179
1 1996 121
2 1992 140
2 1993 187
2 1994 230
2 1995 308
2 1996 80
3 1992 76
3 1993 200
3 1994 190
3 1995 120
3 1996 82
end
into this:
clear
input int(id year x_1)
1 1992 160
1 1992 180
1 1993 120
1 1993 123
1 1994 179
1 1995 180
1 1998 190
1 1996 121
1 1996 130
2 1992 140
2 1992 180
2 1993 187
2 1993 198
2 1994 230
2 1994 160
2 1995 308
2 1995 210
2 1996 80
2 1996 120
3 1992 76
3 1992 134
3 1993 200
3 1993 208
3 1994 190
3 1994 209
3 1995 120
3 1995 170
3 1996 82
3 1996 120
end
Related Posts with Combining panel datasets with the same IDs and years to create advanced graphs
-groups- by functionHello I want to list the "top 10" causes of death by age group. The -groups- command works nicely f…
variable Omitted due to collinearityHi, I am facing the similar problem of collinearity among independent variables but my model contain…
Exponent operator doesn't work with generateCan anyone explain this problem I'm having in Stata 15. I just want to generate a variable which is…
Estimating confidence intervals of the cumulative structural impulse–response functionsHello, I have estimated csirf following the instructions from this post: https://blog.stata.com/201…
Summary stats for panel dataI have the following dataset from years 2000-2010. Code: * Example generated by -dataex-. To insta…
Subscribe to:
Post Comments (Atom)
0 Response to Combining panel datasets with the same IDs and years to create advanced graphs
Post a Comment