I am using Stata/IC 13.1 for Mac (64-bit Intel)
I want to produce 9 box plots of percentages of nine survey responses coded in nine variables pc_q21_`i'. (i=1…9)
The variable labels were defined earlier.For example,the coding for the label of the ninth variable q21_9 is as follows:
label variable q21_9 "Admission cause=none of above"
label define q21_9 9 "yes",modify
label values q21_9 q21_9
Two variables describe the state of residence ("state") and the wave of the survey("wave").There are eight states and three waves.
The following code sets up the loops for nine box plots of the proportions answering yes to each question, thanks to the graph "var label" hints in the new Cox-Newton 119 Stata Tips book, third edition (see page 263), and the egen code hint also due (I think) to Nick Cox in a recent Statalist response
forvalues i=1(1)9 {
egen pc_q21_`i' = mean(100 * (q21_`i' ==`i' & q21_`i' != . )), by(state wave)
tab pc_q21_`i' wave,missing row col
graph box pc_q21_`i' if tag, over(state) ytitle("`:var label q21_`i''") title("Percent of patients in PSS reporting", size(vsmall)) saving(AdmCause`i',replace)
}
Only in the ninth graph does the variable label (in this case "Admission cause=none of above") appear correctly in the ytitle. In the preceding eight graphs,only the relevant pc_q21_`i' appears.
Any ideas?
Paul Gross
I want to produce 9 box plots of percentages of nine survey responses coded in nine variables pc_q21_`i'. (i=1…9)
The variable labels were defined earlier.For example,the coding for the label of the ninth variable q21_9 is as follows:
label variable q21_9 "Admission cause=none of above"
label define q21_9 9 "yes",modify
label values q21_9 q21_9
Two variables describe the state of residence ("state") and the wave of the survey("wave").There are eight states and three waves.
The following code sets up the loops for nine box plots of the proportions answering yes to each question, thanks to the graph "var label" hints in the new Cox-Newton 119 Stata Tips book, third edition (see page 263), and the egen code hint also due (I think) to Nick Cox in a recent Statalist response
forvalues i=1(1)9 {
egen pc_q21_`i' = mean(100 * (q21_`i' ==`i' & q21_`i' != . )), by(state wave)
tab pc_q21_`i' wave,missing row col
graph box pc_q21_`i' if tag, over(state) ytitle("`:var label q21_`i''") title("Percent of patients in PSS reporting", size(vsmall)) saving(AdmCause`i',replace)
}
Only in the ninth graph does the variable label (in this case "Admission cause=none of above") appear correctly in the ytitle. In the preceding eight graphs,only the relevant pc_q21_`i' appears.
Any ideas?
Paul Gross
Comment