Dear Dimitris and Friedrich,
If sample = 1 for all observations, preparing the dataset for
the graph at first may be simpler. That is,
.keep if sample==1
It may be safer to use _preserve or to save data beforehand.
If you need other observations, cycling _separate , by( ) gen( )
with foreach may be another way.
Toyoto
At 06:58 04/07/29 -0700, Friedrich Huebler wrote:
> Dimitris,
>
> This works for me. Is sample = 1 for all observations? Do you use
> other options?
>
> . sysuse auto, clear
> . gen weight2 = 1.2*weight
> . gen weight3 = 1.4*weight
> . graph twoway kdensity weight || kdensity weight2 || kdensity
> weight3
> . graph twoway kdensity weight if foreign==1 || kdensity weight2 if
> foreign==1 || kdensity weight3 if foreign==1
> . graph twoway kdensity weight if foreign==0 || kdensity weight2 if
> foreign==0 || kdensity weight3 if foreign==0
>
> Friedrich Huebler
>
> --- "D.Christodoulou" <[email protected]> wrote:
> > My question concerns the use of -if expression- along with -graph
> > twoway-.
> > When I use the following command:
> >
> > graph twoway kdensity var1 if sample==1 || kdensity var2 if
> > sample==1 ||
> > kdensity var3 if sample==1 || ....
> >
> > ...Stata does not recognise the (repeated) restriction of the - if
> > sample==1 - and plots the whole sample.
> > All I want to do is restrict the sample in a comparable (and
> > desirable)
> > range for all kdensities.
> >
> > What is the correct way to do this?
>
*
* 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/