Hello!
I am using SSC's catplot to create a simple descriptive graph of the age of my sample (with age as a categorical variable). I want to specify the age labels on the x-axis, however, when I use var1opts (as I have seen in the "help catplot" guide), I get no apparent changes in my graph.
Here is the syntax I'm currently using (the variable labels are in spanish):
With this code I get the attached graphic. I think what I am asking may be very simple, however I have been trying to specify the labels with no result.
If anyone knows what the problem is I would appreciate it.
Thanks in advance.
Best regards,
Helena
I am using SSC's catplot to create a simple descriptive graph of the age of my sample (with age as a categorical variable). I want to specify the age labels on the x-axis, however, when I use var1opts (as I have seen in the "help catplot" guide), I get no apparent changes in my graph.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float age_cat byte submission . 0 . 0 . 0 . 0 2 1 2 1 . 0 3 1 2 1 4 1 3 1 3 1 4 1 5 1 4 1 4 1 3 1 4 1 . 0 4 1 5 1 . 0 2 1 . 0 . 0 . 0 3 1 2 1 3 1 3 1 3 1 2 1 . 0 . 0 4 1 . 0 4 1 2 0 . 1 3 0 4 1 4 1 2 1 3 1 3 1 . 0 3 1 4 1 . 0 . 0 . 0 3 1 3 1 4 1 . 0 2 0 5 1 3 1 2 0 . 0 2 1 . 0 2 1 5 1 4 1 2 1 . 0 3 1 4 1 . 0 3 1 . 0 3 1 5 1 3 1 . 0 3 1 4 1 3 1 3 1 5 1 3 1 3 1 . 0 5 1 3 1 4 1 . 0 . 0 . 0 4 1 3 1 . 0 . 0 3 1 . 0 3 1 4 1 . 0 4 1 end label values age_cat labelage label def labelage 2 "De 20 a 29 años", modify label def labelage 3 "De 30 a 39 años", modify label def labelage 4 "De 40 a 49 años", modify label def labelage 5 "De 50 a 59 años", modify
Code:
catplot age_cat if submission==1, percentage var1opts(gap(10) relabel(1 "Menos de 20 años" 2 "20-29 años" 3 "30-39 años" 4 "40-49 años" 5 "50-59 años" 6 "60 años o más")) blabel(bar, position(outside) format (%9.1f) color (black) size(medium)) bar(1, bfcolor(50 43 154) blcolor(50 43 154)) bar(2, bfcolor(50 43 154) blcolor(50 43 154)) bar(3, bfcolor(50 43 154) blcolor(50 43 154)) bar(4,bfcolor(50 43 154) blcolor(50 43 154)) bar(5, bfcolor(50 43 154) blcolor(50 43 154)) bar(6, bfcolor(50 43 154) blcolor(50 43 154)) b1title("") ytitle("Porcentaje (%)", size (medium)) ylabel(0(20)100, labsize(small) nogrid) legend(off) asyvars plotregion(fcolor(white)) graphregion(fcolor(white) lcolor(white)) legend(region(lcolor(white))) recast(bar)
If anyone knows what the problem is I would appreciate it.
Thanks in advance.
Best regards,
Helena
Comment