Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Writing a value from a variable into a macro

From   Neil Shephard <>
Subject   Re: st: Writing a value from a variable into a macro
Date   Fri, 24 Sep 2010 12:41:43 +0000

On Fri, Sep 24, 2010 at 12:31 PM, Palan, Stefan
( <> wrote:
> Hi everybody,
> I would like to write a specific value of a variable in my dataset into a macro. Assume I have a dataset with the two variables "number" and "text". They contain observations like (1, "one"), (2, "two"), (3, "three"), etc. Now I would like to write a specific value into a local macro. For example, I might be looking for the text that goes with the observation with number==2, and would like to assign that value to a local macro. Very amateurishly, I was looking for code similar to the following:
> local v=text if number==2

Assuming there is only ever one value of "text" that corresponds to
each "number" you can...

levelsof text if(number == 2), local(t)
di "`t'"


"One should as a rule, respect public opinion in so far as is
necessary to avoid starvation and to keep out of prison, but anything
that goes beyond this is voluntary submission to an unnecessary
tyranny, and is likely to interfere with happiness in all kinds of
ways..." - Bertrand Russell

Email -
Website -
Photos -

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index