A sequence plot is for a very specific type of dataset, one where there are many sequences all made up of the same elements but in different orders. The sequence plot is one way of visualising the many different sequences together. The best example of a sequence dataset is one which contains many different DNA or RNA sequences. In this example, for ease of generating a random dataset, we look at the different periods to do with work in a large dataset on a number of peoples’ lives. These periods include unemployment, employment, inactivity, and tertiary study.
To create sequence plots in Stata, you first need to download the set of sequence commands from the SSC, which you do in Stata with the following command:
ssc install sq

To generate this graph in Stata, use the following commands:
clear all
set obs 2500
egen id = seq(), from(1) block(5)
egen position = seq(), from(1) to(5) block(1)
generate sequence = .
replace sequence = 1 if id >=1 & id <= 50
replace sequence = 2 if id > 50 & id <= 100
replace sequence = 3 if id > 100 & id <= 120
set seed 34567
replace sequence = runiformint(1,5) if missing(sequence)
label define seqlbl 1 "employment" 2 "unemployment" 3 "inactivity" 4 "vocational education" 5 "higher education"
label values sequence seqlbl
sqset sequence id position
sqindexplot