Hi Everyone
I am a beginner in Stata and would greatly appreciate any help.
I appended data from multiple datasets with similar variables and want to plot a graph for some variables over a few other. I also have a weight variable and a unique identifier for each variable contained in the dataset. All the variables are binary (0/1) except for the weight variable and unique identifier. The data is merged from 20 different sources representing 20 countries.
For one graph, I would like to plot oop_drugs oop_IP oop_OP over cata_nf_40 and cata_tot_10. For the other graph, I want to plot cata_nf_40 cata_tot_10 over hh_nexcap_quintile and hh_urban. I hope to have each indicator for all the countries in the dataset represented by an identifier (ID) which is string. For instance, for the ID variable, Uganda will be "UGA", Cambodia will be "KHM", etc. I also want to apply the population weights [popweight] and label the outputs.
Please how can I do this in Stata? Any ideas will be most appreciated!
I tried using the code below it doesnt execute. Ideally, I would also want to have this for cata_nf_40 and cata_tot_10
Fnd below a sample of my dataset
Thanks again!
I am a beginner in Stata and would greatly appreciate any help.
I appended data from multiple datasets with similar variables and want to plot a graph for some variables over a few other. I also have a weight variable and a unique identifier for each variable contained in the dataset. All the variables are binary (0/1) except for the weight variable and unique identifier. The data is merged from 20 different sources representing 20 countries.
For one graph, I would like to plot oop_drugs oop_IP oop_OP over cata_nf_40 and cata_tot_10. For the other graph, I want to plot cata_nf_40 cata_tot_10 over hh_nexcap_quintile and hh_urban. I hope to have each indicator for all the countries in the dataset represented by an identifier (ID) which is string. For instance, for the ID variable, Uganda will be "UGA", Cambodia will be "KHM", etc. I also want to apply the population weights [popweight] and label the outputs.
Please how can I do this in Stata? Any ideas will be most appreciated!
I tried using the code below it doesnt execute. Ideally, I would also want to have this for cata_nf_40 and cata_tot_10
Code:
levelsof ID, local(levels) . foreach `l' of local levels { . di "-> ID = `: label (ID) `l''" . graph twoway (scatter oop_drugs oop_IP oop_OP cata_nf_40) if factor == `l' . }
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float popweight byte hh_nexpcap_quintile float(oop_drugs oop_OP oop_IP cata_nf_40 cata_tot_10 hh_urban) str3 ID 8377 5 0 0 1 . 1 0 "UGA" 8377 5 0 0 0 . 1 0 "UGA" 8377 3 1 0 0 . 1 0 "UGA" 9373 5 0 0 1 . 0 1 "UGA" 3749 5 1 0 0 . 0 1 "UGA" 1874 5 1 0 0 . 0 1 "UGA" 7499 4 1 0 0 . 0 1 "UGA" 11248 5 1 0 0 . 0 1 "UGA" 11248 5 1 0 0 . 0 1 "UGA" 11248 4 1 0 0 . 0 1 "UGA" 7499 5 0 0 1 . 0 1 "UGA" 11248 5 1 0 0 . 0 1 "UGA" 16873 5 0 1 0 . 0 1 "UGA" 16873 5 1 0 0 . 0 1 "UGA" 16873 5 0 0 1 . 0 1 "UGA" 1874 5 0 1 0 . 0 1 "UGA" 1874 5 1 0 0 . 0 1 "UGA" 1874 5 0 0 1 . 0 1 "UGA" 9373 5 1 0 0 . 0 1 "UGA" 2499 4 0 0 1 . 0 1 "UGA" 3124 5 1 0 0 . 0 1 "UGA" 7499 5 1 0 0 . 1 1 "UGA" 11248 4 1 0 0 . 1 1 "UGA" 11248 4 0 0 1 . 1 1 "UGA" 1874 5 1 0 0 . 1 1 "UGA" 5624 5 0 1 0 . 1 1 "UGA" 5624 5 1 0 0 . 1 1 "UGA" 11248 5 1 0 0 . 1 1 "UGA" 11248 5 0 0 1 . 1 1 "UGA" 9373 4 1 0 0 . 0 1 "UGA" 11248 5 1 0 0 . 0 1 "UGA" 4686 4 1 0 0 . 0 1 "UGA" 13123 5 1 0 0 . 0 1 "UGA" 9373 5 1 0 0 . 0 1 "UGA" 9373 5 0 0 1 . 0 1 "UGA" 7499 5 1 0 0 . 0 1 "UGA" 7499 5 0 0 1 . 0 1 "UGA" 20622 4 1 0 0 . 0 1 "UGA" 11248 4 1 0 0 . 0 1 "UGA" 11248 5 1 0 0 . 0 1 "UGA" 3749 5 1 0 0 . 0 0 "UGA" 7499 5 0 1 0 . 0 1 "UGA" 7499 5 1 0 0 . 0 1 "UGA" 7499 5 0 0 1 . 0 1 "UGA" 7499 5 1 0 0 . 0 1 "UGA" 1874 5 1 0 0 . 0 0 "UGA" 20622 5 0 1 0 . 0 1 "UGA" 20622 5 1 0 0 . 0 1 "UGA" 2812 5 1 0 0 . 0 1 "UGA" 7499 5 1 0 0 . 0 1 "UGA" 2812 5 1 0 0 . 0 1 "UGA" 5624 5 1 0 0 . 0 1 "UGA" 13123 4 0 1 0 . 0 1 "UGA" 13123 4 1 0 0 . 0 1 "UGA" 3749 5 1 0 0 . 0 1 "UGA" 13123 5 1 0 0 . 1 1 "UGA" 13123 5 0 0 1 . 1 1 "UGA" 5624 5 1 0 0 . 0 1 "UGA" 9373 4 1 0 0 . 0 0 "UGA" 9373 5 1 0 0 . 0 1 "UGA" 10206 4 1 0 0 . 0 0 "UGA" 25517 2 0 0 1 . 1 0 "UGA" 10206 5 1 0 0 . 0 0 "UGA" 7655 3 1 0 0 . 0 0 "UGA" 4252 4 1 0 0 . 1 0 "UGA" 10206 3 0 0 1 . 0 0 "UGA" 17861 4 0 0 1 . 0 0 "UGA" 15310 4 1 0 0 . 0 0 "UGA" 15310 4 0 0 0 . 0 0 "UGA" 10206 5 1 0 0 . 1 0 "UGA" 10206 5 0 0 0 . 1 0 "UGA" 15310 4 0 0 1 . 0 0 "UGA" 8930 4 1 0 0 . 0 0 "UGA" 1275 5 1 0 0 . 0 1 "UGA" 10206 3 1 0 0 . 1 0 "UGA" 2551 3 1 0 0 . 1 0 "UGA" 2551 3 0 0 1 . 0 0 "UGA" 15310 5 1 0 0 . 0 1 "UGA" 12758 3 0 0 1 . 0 1 "UGA" 15310 4 1 0 0 . 0 1 "UGA" 10206 4 1 0 0 . 0 0 "UGA" 17861 4 1 0 0 . 0 0 "UGA" 17861 4 0 0 1 . 0 0 "UGA" 10206 5 1 0 0 . 0 0 "UGA" 12758 4 0 0 1 . 0 0 "UGA" 11482 4 1 0 0 . 0 0 "UGA" 28068 5 0 0 1 . 0 0 "UGA" 15310 4 1 0 0 . 1 0 "UGA" 7655 3 0 0 1 . 0 0 "UGA" 1701 5 1 0 0 . 0 1 "UGA" 7655 4 0 0 1 . 0 1 "UGA" 20413 1 1 0 0 . 0 0 "UGA" 5103 4 1 0 0 . 0 0 "UGA" 2551 4 0 0 1 . 1 0 "UGA" 2551 4 0 0 0 . 1 0 "UGA" 1275 5 1 0 0 . 0 0 "UGA" 7655 5 1 0 0 . 0 1 "UGA" 30620 3 1 0 0 . 0 0 "UGA" 10206 5 0 0 1 . 0 1 "UGA" 10206 5 0 0 0 . 0 1 "UGA" end label values hh_nexpcap_quintile hh_nexpcap_quintile label def hh_nexpcap_quintile 1 "poorest", modify label def hh_nexpcap_quintile 2 "poorer", modify label def hh_nexpcap_quintile 3 "middle", modify label def hh_nexpcap_quintile 4 "richer", modify label def hh_nexpcap_quintile 5 "richest", modify
Thanks again!
Comment