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, statalist.org is already up and running.


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

RE: st: AW: create a dataset or vector of variable names


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: AW: create a dataset or vector of variable names
Date   Thu, 25 Feb 2010 19:19:16 +0100

<>

I probably misunderstand your intentions completely, but if all you want is
a new, empty dataset with the same variables as some other dataset, you can
simply gut the latter and -save- it under a new name:


*******
sysuse nlsw88, clear
drop in 1/l
save mynewfile, replace emptyok

use mynewfile, clear
*******


HTH
Martin

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Sheena Sullivan
Sent: Donnerstag, 25. Februar 2010 18:41
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: AW: create a dataset or vector of variable names

Thanks very much for that.  To sum, I did the following 


use mydata, clear
ssc inst descsave
descsave, sa(varname)  keep(name)
use varname
li

forval i = 1/109 { 			
	local names `names' `=name[`i']' 
}
matrix colnames R = `names' 
clear
svmat mymat, names( col )


which gave me a dataset from my matrix with the appropriate variables names.
Thanks again,
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/


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