[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 |
st: AW: from value to varnames |

Date |
Mon, 18 May 2009 22:55:16 +0200 |

<> ************* clear* input str10 field str5 cat order namea A 1 nameb B 2 namec F 5 named T 12 end //compress list, noobs forv i=1/`=_N'{ egen `=field[`i']' = concat(cat order) } //counter to -replace- redundant stuff... local cou =0 foreach var of varlist nam*{ loc ++cou replace `var'="" if _n!=`cou' } list, noo ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Richard Goldstein Gesendet: Montag, 18. Mai 2009 22:41 An: statalist Betreff: st: from value to varnames Hi, I have a data set with 3 variables: field, cat, order; there are 258 observations I want the 258 observations in field to be 258 variables where the name of the value in field becomes the new variable name; I want to keep the associated values of the other two fields For example, say that the first observation has the following values: field cat order namea A 1 I want a new set of variables such that I have a variable called "namea" and I still have cat (of "A") and order (of "1") -- but remember that I should now have 258 variables--cat and order can be joined as the value for each variable; thus, for the example above, the first variable (namea) would now have the value "A1" I hope that this is sufficiently clear (note that there is no pattern in the values of field (the new varnames) thanks, Rich * * 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: from value to varnames***From:*Richard Goldstein <richgold@ix.netcom.com>

- Prev by Date:
**Re: st: Aggregate and Microdata** - Next by Date:
**st: AW: Aggregate and Microdata** - Previous by thread:
**st: from value to varnames** - Next by thread:
**Re: st: from value to varnames** - Index(es):

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