Dear Statalists,
im trying to create a graph (multiple graphs at the end) which should look something like this:

The straight horizontal line would be my "baseline" group and the other line depicts how the other group changes over age in comparison.
My dataset contains 4 variables (sex age meanwork minworkage) with 70 observations and contains information on the average of children working at different ages sorted by sex and the legal minimum working age from the region they are living in.
My Goal is to set one of the regions as a “baseline” (the one where minworkage==14) and then analyse how the percentage of working children at different ages deviates from that in other regions, where there is a different minimum working age (supposedly the legal working age should affect the amount of children working).
My first attempt was to create the graph directly, however I couldn’t find any way to set one group as “baseline”.
The next idea was to create a new variable first, which simply contains the difference between the meanwork in region x and the meanwork in region (minworkage=14) per sex and age:
replace diff_working_children= work-work[15] if age==10 & sex==1 /* observation [15] contains age==10 from minworkage==14 for sex==1
The command works, but I have to manually change and repeat it for every age and gender for the whole table. I couldn’t find a way for the “work[15]” to automatically choose the correct comparison age from group (minworkage==14).
Is there a more efficient way to create the new variable in one line of code?
I added the data sample as an attachment (the variable "diff_working_children" already contains some nonsense data from my experiments).
Thank you in advance for your help!
Sincerely,
Adrian
im trying to create a graph (multiple graphs at the end) which should look something like this:
The straight horizontal line would be my "baseline" group and the other line depicts how the other group changes over age in comparison.
My dataset contains 4 variables (sex age meanwork minworkage) with 70 observations and contains information on the average of children working at different ages sorted by sex and the legal minimum working age from the region they are living in.
My Goal is to set one of the regions as a “baseline” (the one where minworkage==14) and then analyse how the percentage of working children at different ages deviates from that in other regions, where there is a different minimum working age (supposedly the legal working age should affect the amount of children working).
My first attempt was to create the graph directly, however I couldn’t find any way to set one group as “baseline”.
The next idea was to create a new variable first, which simply contains the difference between the meanwork in region x and the meanwork in region (minworkage=14) per sex and age:
replace diff_working_children= work-work[15] if age==10 & sex==1 /* observation [15] contains age==10 from minworkage==14 for sex==1
The command works, but I have to manually change and repeat it for every age and gender for the whole table. I couldn’t find a way for the “work[15]” to automatically choose the correct comparison age from group (minworkage==14).
Is there a more efficient way to create the new variable in one line of code?
I added the data sample as an attachment (the variable "diff_working_children" already contains some nonsense data from my experiments).
Thank you in advance for your help!
Sincerely,
Adrian
Comment