Statalist The Stata Listserver


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

st: RE: -separate- command


From   "Feiveson, Alan H. (JSC-SK311)" <alan.h.feiveson@nasa.gov>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: -separate- command
Date   Fri, 27 Jan 2006 08:03:25 -0600

Amazing! - How long has this -separate- command been in existence? I
have been doing this by hand since Stata 3. 

Al F.

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Thursday, January 26, 2006 4:30 PM
To: statalist@hsphsun2.harvard.edu
Subject: -separate- command

Starting from where you left off: 

. separate mpg, by(mpg>20) 

              storage  display     value
variable name   type   format      label      variable label
------------------------------------------------------------------------
-------
mpg0            float  %8.0g                  mpg, !(mpg>20)
mpg1            float  %8.0g                  mpg, mpg>20

. egen group = group(mfg), label 

. gen group2 = group + cond(year == 1990, -0.2, 0.2) 

. twoway scatter mpg group
, yla(0(5)40, ang(h)) xla(1/9, notick valuelabel) ms(none) 
|| bar mpg0 group2 , base(0) barw(0.4)
|| bar mpg1 group2 ,
base(0) bcolor(yellow) barw(0.4) legend(off) ytitle(Miles per gallon) 

Old Stata saying: "When you run into a wall with -graph bar-, jump over
it with a -twoway bar-." (Loses a bit in translation from British.) 

Nick
n.j.cox@durham.ac.uk 

H Wright
 
> Given this example, is it possible to have the bars with greater than 
> 20mpg come up in some other color, like yellow?
> 
> Thank you for any help.
> -----------------------------------
>    sysuse auto,
> 
>       gen mfg=word(make,1)
>       sort mfg fore
>       by mfg fore: keep if _n>3
> 
>       * now there is a reasonable size
> 
>       collapse mpg, by(mfg fore)
>       save temp, replace
>       gen year=1990
>       append using temp
>       replace year=2000 if year==.
>       replace mpg=mpg*1.1 if year==2000
> 
>       graph bar mpg, over(year) over(mfg) asyvars
> 

*
*   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/



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