[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: Function to assign a value label to a global marco |

Date |
Fri, 14 Oct 2005 17:43:18 +0100 |

For similar problems in future you may want to check out -separate-. Thus the lines gen outcome1 = `outcome' if `uvar'==1 global label1 : label (`uvar') 1 gen outcome0 = `outcome' if `uvar'==0 global label0 : label (`uvar') 0 are likely to be equivalent to separate `outcome', by(`uvar') veryshortlabel In a program what you have is more efficient, but interactively -separate- is less work. The topic of percent summaries, including graphics, was discussed recently on the list and an FAQ is now visible at http://www.stata.com/support/faqs/data/percentvars.html Nick n.j.cox@durham.ac.uk Lars E. Kroll > Thank you Thomas & Fred, > > Sorry, I didn't answer but I got that function right after > Fred's hint > to h extended_fcn ... > > Lars > > P.S. > Here's my Code which draws an bar chart if someone is > interested in it: > outcome is a probabolity and uvar is 0/1 coded > [snip] > foreach outcome in Y1 Y2 { > foreach uvar in X1 X2 { > gen outcome1 = `outcome' if `uvar'==1 > global label1 : label (`uvar') 1 > gen outcome0 = `outcome' if `uvar'==0 > global label0 : label (`uvar') 0 > graph bar (mean) outcome1 outcome0 [pw=phrf] if jahr==2003, /// > over(`uvar' , label(nolabels)) /// > over(alter_gr4) outergap(25) bargap(-90) /// > ylabel(0 "0%" .10 "10%" .20 "20%" .30 "30%" .40 "40%" .5 "50%" /// > .60 "60%" .70 "70%" .80 "80%" .90 "90%" 1.0 "100%" , > angle(horizontal)) /// > xsize(3.9375) ysize(2.95) scheme(lean2) bar(1, fcolor(navy*.6)) > bar(2, fcolor(navy)) /// > legend(order(2 "${label0}" 1 "${label1}" )textfirst cols(2) > position(6) symxsize(medium)) > graph export > "${arbeitsverzeichnis}Grafiken/deskriptiv/`outcome'_`uvar'.eps > ", replace > drop outcome* > } > } > > > > Steichen, Thomas J. schrieb: > > Fred Wolfe said to see extended functions... He's right, > but you want _macro_ > > extended functions, so start with macro first. > > > > Here's the diagram for what you want: > > > > {local | global} macname : label { valuelabelname | (varname) } { > > maxlength | # [#] } [, strict ] > > > > Thus" > > global myvaluelabel : label mylabel 1 > > > > And if, say, mylabel was the value label for variable > myvar, you could > > directly do: > > global myvaluelabel : label (myvar) 1 > > And Stata will figure out which value label you want. > > > > Tom > > > > > >>On Behalf Of Lars E. Kroll > >>Sent: Friday, October 14, 2005 7:08 AM > >>To: statalist@hsphsun2.harvard.edu > >>Subject: st: Function to assign a value label to a global marco > >> > >> > >>Dear all, > >> > >>I'm trying to do the following: > >> > >>. label define mylabel 1 "Hello" 2 "Good Bye" > >>. global myvaluelabel UNKNOWNFUNCTION(mylabel,1) > >>. di "{$myvaluelabel} XY!" > >>HELLO XY! > >> > >>But I don't know the UNKNOWNFUNCTION and I didn't find an > information > >>about. But I know that it is possible.. > >> > >>(In fact I want to assign the value label to a legend in an > >>overlaid tw > >>graph.. ) > >> > >>I hope someone can help me.. > >> > >>Lars > >> > >>-- > >>____________________________ > >>Lars E. Kroll > >>UNI 030 83857614 > >>RKI 030 45473307 > >>Privat 0176 23131352 > >>FAX 069 13306720084 > >>WEB www.lkroll.de > >>* > >>* For searches and help try: > >>* http://www.stata.com/support/faqs/res/findit.html > >>* http://www.stata.com/support/statalist/faq > >>* http://www.ats.ucla.edu/stat/stata/ > >> > > > > > > ----------------------------------------- > > CONFIDENTIALITY NOTE: This e-mail message, including any > attachment(s), > > contains information that may be confidential, protected by the > > attorney-client or other legal privileges, and/or proprietary non- > > public information. If you are not an intended recipient of this > > message or an authorized assistant to an intended recipient, please > > notify the sender by replying to this message and then > delete it from > > your system. Use, dissemination, distribution, or > reproduction of this > > message and/or any of its attachments (if any) by > unintended recipients > > is not authorized and may be unlawful. > > > > > > * > > * For searches and help try: > > * http://www.stata.com/support/faqs/res/findit.html > > * http://www.stata.com/support/statalist/faq > > * http://www.ats.ucla.edu/stat/stata/ > > > > > -- > ____________________________ > Lars E. Kroll > UNI 030 83857614 > RKI 030 45473307 > Privat 0176 23131352 > FAX 069 13306720084 > WEB www.lkroll.de > * > * For searches and help try: > * http://www.stata.com/support/faqs/res/findit.html > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**Re: st: pweights and -table-** - Next by Date:
**st: Constrained Nonlinear Least Squares** - Previous by thread:
**Re: st: RE: Function to assign a value label to a global marco** - Next by thread:
**st: Re: running segments of a do-file** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |