Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: AW: using extended macros to title graphs

From   "Nick Cox" <>
To   <>
Subject   RE: st: AW: using extended macros to title graphs
Date   Mon, 29 Mar 2010 16:48:05 +0100

I guess the problem lies here:  

title("Causes   `=varlabs[`vars[`i']']'")

should be 

title("Causes   `=varlabs[`=vars[`i']']'")

as the inner and outer macro manipulations are completely independent.
Otherwise put, 


is not the name of a local macro. 


David Souther

I am trying to use extended macro functions to title a graph with
the value in one string variable that corresponds to another variable.

So, a condensed version of my data looks like:

inp str35 vars str25 varlabs participant_type1 participant_type2
"children_with_mental_illness_" "Children with MI" .4 .5 1
"communitywide_prevention_init" "Community-wide prevention" .2 .9 0
"differences_between_families_" "Conflict between families " .3 .2 0
"dysfunctional_or_broken_famil" "Dysfunctional " .47 .29 0
"greater_access_to_diversion_o" "Greater access " .2 .5 1
"greater_tolerance_and_cultura" "Greater tolerance " .6 .2 1
"high_levels_of_transience_and" "High levels " .5 .2 0
"holding_juvenile_offenders_mo" "Holding " .4 .4 0
"homeless_youth_face_special_c" "Homeless " .2 .4 0
"immigrant_youth_face_special_" "Immigrant " .2 .3 1

I want to graph participant_type(s) for specific conditions (one of
the "vars" in `tc' and indicator==1) while adding the corresponding
"varlabs" title, here's what I tried (and didn't work):

local tc  dysfunctional_or_broken_famil  greater_tolerance_and_cultura
foreach i in `tc' {
graph hbar (asis) participant_type1 participant_type2  if indicator==1
& "`i'"==vars,  ///
nofill   bargap(4.5) blabel(bar, size(medium) position(outside)
format(%4.2f))  ///
ytitle(%Responses) title("Causes   `=varlabs[`vars[`i']']'")  ///
legend(size(vsmall)) name(g1, replace)   ///
subtitle(, size(small) span bexpand) graphregion(margin(tiny))
*graph save g1 "g1.gph", replace
*graph export "causes_`i'_participanttype.pdf", as(pdf) replace name(g1)

*   For searches and help try:

© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index