Hi,

Question 1:
I have a dataset with patent count, a dummy to check wheter a firm engages in a M&A (0 for noM&A, 1 for M&A). And for the M&A=1 group, that does engage in M&A I have data to check the relatedness (SICMatch, scores 0 up to and including 4).I want to do two different things. First of all I want to plot confidence intervals to a graph I already generated to show whether the differences are significant. I use the following code for the graph. An example of how I want it to look is also included in the image below.


Code:
preserve 
collapse lnPatents, by(d_MA time)
xtset d_MA time
xtline lnPatents if d_MA, overlay addplot(line lnPatents time if !d_MA) xline(0)
restore
This gives the following result

Array

Array
Second question
My other question is that I want to generate a graph with the patents on the Y axis, and the SICMatch variable on the x axis, only for the M&A=1 variable. However I'm not able to do this because I think I also have to use the collapse function but this does not work. Below you find the data that I use.



Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float lnPatents byte SICMatch
 8.148446 4
  8.02027 4
 7.887584 4
 7.828436 4
 7.860185 4
  7.84659 4
 7.608871 4
 2.944439 0
2.0794415 0
2.1972246 0
 2.833213 0
 2.397895 0
 2.995732 0
 2.995732 0
 3.465736 4
3.0445225 4
 2.995732 4
 2.890372 4
 2.944439 4
 2.772589 4
1.7917595 4
 5.828946 0
 5.843544 0
 5.686975 0
 6.079933 0
 6.173786 0
 5.869297 0
 5.874931 0
 5.929589 .
 5.616771 .
 5.288267 .
 5.298317 .
  5.31812 .
  4.89784 .
4.1271343 .
 8.869961 0
 8.879473 0
 8.945202 0
8.8934355 0
 8.802672 0
 8.610683 0
 8.410499 0
 4.634729 4
 4.564348 4
4.4426513 4
4.6051702 4
 4.454347 4
 4.624973 4
 2.833213 4
 4.454347 1
  4.75359 1
  4.94876 1
 4.454347 1
 4.564348 1
 4.969813 1
 4.189655 1
 3.912023 0
3.4011974 0
 3.496508 0
  3.89182 0
3.4011974 0
3.8501475 0
3.6888795 0
1.7917595 .
2.3025851 .
 1.609438 .
1.3862944 .
1.3862944 .
1.0986123 .
  2.70805 .
 8.344267 0
 8.353025 0
  8.31189 0
  8.18144 0
 7.872074 0
 7.728416 0
 7.619234 0
 2.995732 .
3.2580965 .
2.1972246 .
  2.70805 .
1.0986123 .
 1.609438 .
 1.609438 .
 6.082219 .
 5.863631 .
 5.831882 .
 5.783825 .
 5.659482 .
 5.652489 .
 4.828314 .
  4.26268 .
 4.787492 .
 4.394449 .
 4.454347 .
3.4011974 .
4.4308167 .
4.0775375 .
  4.75359 3
 3.583519 3
end