Statalist


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

RE: st: nesting commands


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   stata list <statalist@hsphsun2.harvard.edu>
Subject   RE: st: nesting commands
Date   Tue, 6 May 2008 19:45:49 +0100 (BST)

> Suppose I generate a variable and then have a histogram on the 
> generated variable:
>
> gen ab=1-b
> hist ab, disc freq
>
> Is it possible to nest the gen command in the hist command:
>
> hist (gen ab=a-b), disc freq
>
> This is, by command, not possible but what would be the syntax for
> this purpose? I searched for nesting in stata but could not find
> really what I want to do.

There is a good reason why you could not find that, because it can't be
done. The only special case where something like this is possible is
with categorical variables than can be split up in dummies in commands
that allow the -xi- or -xi3- prefix. (-xi- is part of official Stata, 
-xi3- is user written and can be downloaded by typing -findit xi3-)
Generally, I think that the absence of this capability is a good thing:
It forces you to write code step by step, leading to more readable,
less bug prone code.

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index