Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

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


From   David Souther <[email protected]>
To   [email protected]
Subject   Re: st: AW: using extended macros to title graphs
Date   Mon, 29 Mar 2010 10:29:51 -0500

..
..



I didn't notice that, thanks Martin.  Here is the post again:

_____________________

Hi:  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:

clear
inp str35 vars str25 varlabs participant_type1 participant_type2 indicator
"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
end


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
 immigrant_youth_face_special_
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))
plotregion(margin(vsmall))
*graph save g1 "g1.gph", replace
*graph export "causes_`i'_participanttype.pdf", as(pdf) replace name(g1)
}

Thanks for any insights,  D.S.
_____________________________



On Mon, Mar 29, 2010 at 10:25 AM, Martin Weiss <[email protected]> wrote:
>
> <>
>
>
> Your initial post got chopped by the server, so you may want to restate your
> query. I may have misunderstood it...
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von David Souther
> Gesendet: Montag, 29. März 2010 17:17
> An: [email protected]
> Betreff: Re: st: AW: using extended macros to title graphs
>
> On Mon, Mar 29, 2010 at 10:09 AM, Martin Weiss <[email protected]> wrote:
>>
>> <>
>> One problem: you rename your graphs as -name(g1, replace)- every time
>> through the loop, so you will end up with only one graph - the last one
>> created...
>>
>
> No, this isn't an issue because I -graph save- and -graph export- the
> file with a different name (dependent upon `i') each time I pass thru
> the loop.
>
>
>>
>> Look at - help extended_fcn- to get your hands on the var labels...
>>
>
> I have looked at the help file and cannot figure out how to get it to
> work in this case (please note that the variable "varlabs" is not the
> same as a variable label because of the way the data are shaped).
> So, in addition to "title("Causes   `=varlabs[`vars[`i']']'")" to
> create the graph title,   I've tried things like:
>
> title("Causes   `varlabs[`vars']'")
> title("Causes   `=varlabs[`vars[`i']']'")
> title("Causes   `=varlabs[`=vars[`i']']'")
> etc...
>
> but I cannot decipher the help documentation for extended functions to
> get this to work.
>
>
>
>
>>
>> HTH
>> Martin
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: [email protected]
>> [mailto:[email protected]] Im Auftrag von David Souther
>> Gesendet: Montag, 29. März 2010 17:03
>> An: [email protected]
>> Betreff: st: using extended macros to title graphs
>>
>> the value in one string variable that corresponds to another variable.
>>
>> So, a condensed version of my data looks like:
>>
>> clear
>> inp str35 vars str25 varlabs participant_type1 participant_type2 indicator
>> "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
>> end
>>
>>
>> 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
>>  immigrant_youth_face_special_
>> 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))
>> plotregion(margin(vsmall))
>> *graph save g1 "g1.gph", replace
>> *graph export "causes_`i'_participanttype.pdf", as(pdf) replace name(g1)
>> }
>>
>> Thanks for any insights,  D.S.
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index