From the course: Advanced and Specialized Statistics with Stata

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Graphing by groups

Graphing by groups

Let's examine how we can graph by groups. Stata can quickly graph over multiple groups using the by option. While similar effects can be achieved with the if condition this usually takes a lot more code. The by option avoids this problem and makes visual data exploration faster and more efficient. Here's an example of a graph that was made using the by option. This graph consists of many smaller sub-graphs that repeat the command over the sub-groups specified with by. It's a great way to do a lot of graphical analysis quickly. The graph also uses several visual options that we'll explore in this session. The Stata option that we're going to use in this session is the by option which can be used with any Stata graph. The by option will repeat the requested Stata graph for each value of the viable list specified in the by option, and yes you can specify multiple variables. The by option also has a series of sub-options…

Contents