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, **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 |
st: AW: create a dataset or vector of variable names |

Date |
Wed, 24 Feb 2010 17:36:04 +0100 |

<> ************* sysuse auto, clear d, varlist gen str30 varnames="" loc i 1 foreach var of varlist `r(varlist)'{ replace varnames="`var'" in `i' loc ++i } keep varnames l in 1/20 ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Sheena Sullivan Gesendet: Mittwoch, 24. Februar 2010 17:27 An: statalist@hsphsun2.harvard.edu Betreff: st: create a dataset or vector of variable names I would like to create a dataset of the variable names in a dataset (could also be a vector). I have created data using matrices and would like to append it to my actual data, but I want to avoid having to manually type up the variable names, which I believe I will need to have in order to append the created data to the actual data. In SAS, I can do this using a proc contents step proc contents data=dataset out=varname position noprint; run; which creates a dataset call varname. but I'm trying to move away from SAS these days! I read that I can get a variable list using describe, varlist but I can't figure how I can then use r(varlist) to assign variable names. What I would ideally like is something like this: mat colnames mymatrix = r(varlist) if you get what I mean. In SAS it is simply a matter of assigning [colnames=varlist] when creating a dataset from a matrix. Any thoughts would be greatly appreciate as I have more than 100 variables. Thanks, Sheena * * 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/

**Follow-Ups**:**Re: st: AW: create a dataset or vector of variable names***From:*Eric Booth <ebooth@ppri.tamu.edu>

**References**:**st: create a dataset or vector of variable names***From:*"Sheena Sullivan" <sheena.sullivan@gmail.com>

- Prev by Date:
**Re: st: AW: create a dataset or vector of variable names** - Next by Date:
**AW: st: AW: create a dataset or vector of variable names** - Previous by thread:
**AW: st: AW: create a dataset or vector of variable names** - Next by thread:
**Re: st: AW: create a dataset or vector of variable names** - Index(es):