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

RE: st: nesting commands

From   Maarten buis <>
To   stata list <>
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 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

Sent from Yahoo! Mail.
A Smarter Email
*   For searches and help try:

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