Lars Korsholm wrote:
> Can anyone help me with the following
> what I would like to do is something like
> local val= x if id==124
>
> I know one dirty way:
> preserve
> keep if id==124
> local val=x
> restore
Lars, I do not understand exactly what you wish to accomplish. Perhaps you
mean:
if id == 124 local val=x
This will set val = x only if id == 124 and, if x is a variable, the value
of val will be x[1] (the value of the first observation of x). val will not
exist if there is no id with value 124 and val did not exist prior to the
above command.
If, as I suspect, you want val to have value x[124], you will need to
explicitly set it:
if id == 124 local val=x[124]
The -if id == 124- part may not be needed depending on the logic of your
program... if so, just set
local val=x[124]
Tom
*
* 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/