Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: create a dataset or vector of variable names

From   "Sheena Sullivan" <>
To   <>
Subject   st: create a dataset or vector of variable names
Date   Wed, 24 Feb 2010 08:26:47 -0800

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;

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.


*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index