Hello, I have the following dataset:
clear
input str1 item year1 year2 year3 year4 year5
"A" 1 0 0 0 1
"B" 0 0 0 1 1
"C" 1 1 1 1 1
"D" 1 0 0 0 0
"E" 1 1 1 0 0
end
The data shows that, for instance, item A occurs in year 1 and year 5 but not in year 2, 3 and 4.
I would like to show this in a graph where the item variable is on the y-axis and the year1, year2, year3, year4 and year5 variables are on the x-axis. For item A, for instance, there would be a marker for year 1 and year 5 but there would be no marker for year 2, 3 and 4.
Ideally, the y-axis would be sorted according to the sum of items' occurences, so item D would be at the bottem end of the y-axis and item C at the top end of the y-axis.
I have tried graph dot and twoway dot with multiple versions of reshaped data but I cannot produce the graph I want.
Any suggestions? Thank you!
Related Posts with Dot plot for two categorical variables
Deleting observations from a panel data according to a criteriaHi, I am quite new to STATA (shame on me) and am trying to figure out how to get a desired dataset …
Capturing confidence intervals in newly generated variablesHi, I'm using the following code to determine the 95%CI of a proportion: cii means n_sample n_case…
How to fit a zero-inflated poisson model in GSEM?Hi friends, BACKGROUND: I have checked all examples showed in SEM/GSEM, but I do not find any examp…
Controlling for gender in linear regressionHello Statalist! This is my first ever post, and I am newly learning Stata as a somewhat-competent u…
subtracting datesPlease help. In my data set the dates are in the format: 17dec2016 00:00:00. I am trying to subtract…
Subscribe to:
Post Comments (Atom)
0 Response to Dot plot for two categorical variables
Post a Comment