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: Re: Scatterplot of mean values


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Re: Scatterplot of mean values
Date   Wed, 31 Mar 2010 12:21:25 +0000 (GMT)

--- On Wed, 31/3/10, Fernando Terrés wrote:
> Let us say that, in the auto.dta dataset, I want to plot
> the mean values of mileage against the mean values of
> weight, both means grouped by repair record.
> I could do:
> 
> *************
> sysuse auto, clear
> collapse mpg weight, by(rep78)
> twoway (scatter mpg weight)
> *************
> 
> My problem is that I need to do the same task for several
> categorical variables of a large file, and every collapse
> forces me to upload the dataset again.

*---------------------- begin example ---------------
sysuse auto, clear
foreach var of varlist rep78 foreign {
    preserve
    collapse mpg weight, by(`var')
    twoway scatter mpg weight if `var' < .,    /// 
           mlabel(`var') mlabpos(0) msymbol(i) ///
           name(`var', replace)
    restore
}
*----------------- end example -----------------------

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

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