Dear Statalisters,
Please consider this dataset. I've hidden sensitive data so it may not make sense here.
I want every variable stored in this toy example to appear in a dot plot but I can't really know how to do this as I'm new in Stata.
year: it should be my X-axis variable
rank: it should be my Y-axis variable
section: it is a binary variable. For each year, I want the plot to show horizontal spacing depending on whether section == 0 or section == 1. All the section == 0 observations should be at the left of the year, and all the section == 1 observations should be at the right of the year.
id: I want dot sharing the same id to have the same color.
name: I want the values contained in name to be shown alongside the dot.
At the end of the day, it should look like this (forgive my Paint skills!)
As you can see whatever1 in 1986 became whatever2 in 1992, and it also changed order. But they are the same color because they would have the same ID. Please also note that year-rank combo is a unique identifyer, so there will never be two points sharing the same Y in the same year. I would also like the Y scale to be reverse so that the dot plot truly looks like a small questionnaire with the order of questions!
Please help me!
Best regards.
Please consider this dataset. I've hidden sensitive data so it may not make sense here.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte rank str4 year str107 name byte section str10 id 24 "1986" "reorieofoefi" 1 "ID1" 28 "1986" "reor" 1 "ID2" 19 "1992" "kdsfsof" 1 "ID2" 52 "1992" "peproz" 1 "ID3" 58 "1992" "ofkoof" 1 "ID4" 1 "1998" "fpdsofps" 0 "ID5" 9 "1998" "zrpzorz" 1 "ID6" 16 "1998" "mflmsf" 0 "ID2" 9 "2004" "opzrpoz" 1 "ID7" 18 "2004" "spfopdsof" 1 "ID2" 24 "2004" "spffods" 1 "ID8" 25 "2004" "psdlmv" 0 "ID9" 38 "2004" "pfo^zfz" 1 "ID10" 30 "2010" "kvxlmmkldg" 1 "ID11" 33 "2014" "vpssklgs" 1 "ID12" 45 "2014" "sokozkv" 0 "ID13" 46 "2014" "vklsklkzg" 0 "ID14" 14 "2017" "kvskkozkgo" 0 "ID15" end
year: it should be my X-axis variable
rank: it should be my Y-axis variable
section: it is a binary variable. For each year, I want the plot to show horizontal spacing depending on whether section == 0 or section == 1. All the section == 0 observations should be at the left of the year, and all the section == 1 observations should be at the right of the year.
id: I want dot sharing the same id to have the same color.
name: I want the values contained in name to be shown alongside the dot.
At the end of the day, it should look like this (forgive my Paint skills!)
As you can see whatever1 in 1986 became whatever2 in 1992, and it also changed order. But they are the same color because they would have the same ID. Please also note that year-rank combo is a unique identifyer, so there will never be two points sharing the same Y in the same year. I would also like the Y scale to be reverse so that the dot plot truly looks like a small questionnaire with the order of questions!
Please help me!
Best regards.
Comment