Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
AW: st: Writing a value from a variable into a macro |

Date |
Fri, 24 Sep 2010 15:22:06 +0200 |

<> " With _really_ I mean: number contains only (a) positive integer numbers (b) each number exist only once (c) no gaps in between two subsequent integer numbers (d) no missings " If (a)-(d) were not fulfilled, we could always ************* gen int number=_n ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Ulrich Kohler Gesendet: Freitag, 24. September 2010 14:45 An: statalist@hsphsun2.harvard.edu Betreff: Re: st: Writing a value from a variable into a macro Am Freitag, den 24.09.2010, 14:31 +0200 schrieb Palan, Stefan (stefan.palan@uni-graz.at): > 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 > > Unfortunately, that doesn't work. Can somebody help me with some code that would actually work? If your dataset _really_ is as you described you can . sort number . local v = text[2] With _really_ I mean: number contains only (a) positive integer numbers (b) each number exist only once (c) no gaps in between two subsequent integer numbers (d) no missings Otherwise the above will fail. Uli * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Writing a value from a variable into a macro***From:*"Palan, Stefan (stefan.palan@uni-graz.at)" <stefan.palan@uni-graz.at>

**Re: st: Writing a value from a variable into a macro***From:*Ulrich Kohler <kohler@wzb.eu>

- Prev by Date:
**st: AW: Writing a value from a variable into a macro** - Next by Date:
**Re: st: AW: TABOUT - Question / with exp.png** - Previous by thread:
**Re: st: Writing a value from a variable into a macro** - Next by thread:
**AW: st: Writing a value from a variable into a macro** - Index(es):