I am trying to produce some graphs in a loop for different countries. For each country, I've computed some statistics which in some case match official data, in others they don't. I want to add to each country graph a note with a warning that says whether or not the statistic matches the official one. If two statistics do not match, each warning should be on a new line.
Without using the local, this is straightforward: each warning should just be within double quotes.
When I try to do it via local the first warning gets all "crumpled up" .

This is my data structure.
and here is my code
Without using the local, this is straightforward: each warning should just be within double quotes.
When I try to do it via local the first warning gets all "crumpled up" .
This is my data structure.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str32 country int decob double(age_marr fgc cowives_any) float(age_marr_flag fgc_faith_flag cowivesany_flag) "mozambique" 1940 16.9 . .3 0 . 1 "mozambique" 1950 17.2 . .3 0 . 1 "mozambique" 1960 17.6 . .3 0 . 1 "mozambique" 1970 17.9 . .3 0 . 1 "mozambique" 1980 18.1 . .2 0 . 1 "mozambique" 1990 18 . .1 0 . 1 "senegal" 1940 16 . .6 0 1 1 "senegal" 1950 16.5 .3 .6 0 1 1 "senegal" 1960 17.6 .3 .5 0 1 1 "senegal" 1970 19.5 .3 .4 0 1 1 "senegal" 1980 19.9 .3 .3 0 1 1 "senegal" 1990 20.7 .2 .2 0 1 1 end
Code:
sort country decob local countries benin senegal local marr_desc "Could not replicate official results for median age at marriage for this country" local fgc_desc "Could not replicate official results for share of cut women for this country" local wives_desc "Could not replicate official results for polygyny for this country" foreach country of local countries { qui sum age_marr_flag if country=="`country'" if r(max)==1 { local add_note_marr = 1 } qui sum fgc_faith_flag if country=="`country'" if r(max)==1 { local add_note_fgc = 1 } qui sum cowivesany_flag if country=="`country'" if r(max)==1 { local add_note_wives = 1 } local nota if `add_note_marr' == 1 { local nota "`marr_desc'" } if `add_note_fgc' == 1 { local nota `nota' "`fgc_desc'" } if `add_note_wives' == 1 { local nota `nota' "`wives_desc'" } twoway line fgc cowives_any age_marr decob if country=="`country'", title("`country'") note(`nota') }
Comment