I find Stata graphing to be a bit challenging sometimes.
I have a data set of study participants, and would like a more granular view of their age at the time they enrolled in the study. I would like to show this command:
histogram age, freq
as a line graph showing the number of persons who are 18 years old, 19 years old, 20 years old, etc., represented not as a series of bars but as a line connecting the dots represented by the frequency of each age in my dataset. Then I would like to show two lines, one for persons in study arm A, one for persons in study arm B. I got close with this command:
twoway (kdensity age if study_arm==0) (kdensity age if study_arm==1)
but it's not exactly showing me the frequencies of persons at each age, but rather kernel-density plots. Maybe this is close enough, if I'm able to relabel axes?
twoway seems to want me to graph age by another variable. Same with the line command.
I feel like this should be a lot easier than it is, but I'm struggling here.
I have a data set of study participants, and would like a more granular view of their age at the time they enrolled in the study. I would like to show this command:
histogram age, freq
as a line graph showing the number of persons who are 18 years old, 19 years old, 20 years old, etc., represented not as a series of bars but as a line connecting the dots represented by the frequency of each age in my dataset. Then I would like to show two lines, one for persons in study arm A, one for persons in study arm B. I got close with this command:
twoway (kdensity age if study_arm==0) (kdensity age if study_arm==1)
but it's not exactly showing me the frequencies of persons at each age, but rather kernel-density plots. Maybe this is close enough, if I'm able to relabel axes?
twoway seems to want me to graph age by another variable. Same with the line command.
I feel like this should be a lot easier than it is, but I'm struggling here.
Comment