Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Generate variable


From   Robert A Yaffee <bob.yaffee@nyu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Generate variable
Date   Mon, 09 May 2005 02:39:30 -0400

Kelly,
  gen obsno = _n
  - Bob Yaffee


2100 Linwood Avenue
Apt 19-W
Fort Lee, NJ
07024-3171
Phone: 201-242-3824
Fax: 201-242-3825
yaffee@nyu.edu

----- Original Message -----
From: kelly johnson <econometrics@hotmail.com>
Date: Sunday, May 8, 2005 9:46 pm
Subject: st: Generate variable

> Hi,
> 
> A few quick questions:
> 
> (1) How do I generate a new variable in a dataset that is equal to 
> the 
> observations number? eg. suppose have data like:
> 
> var1 var2
> 12  43
> 12  23
> .    .
> .   .
> 1   32
> 
> how do I create a new variable, t, that is 1 for the first 
> observation, 2 
> for teh second, 3 for the third, etc.?
> 
> (2) I am using the stata -rolling- command (new to stata 9) to 
> generate 
> rolling correlations. if i declare my data set to be a time sereis 
> dataset 
> using the date variabe (format: %dD_m_Y) it doesn't work. however, 
> when i 
> use a new variable for observations (eg. like the one above, where 
> it equals 
> 1 for the first obs, 2 for the second observation, ...) and declare 
> the data 
> to be time series (tsset) on this variabel, it works. Why?
> 
> (3) also, can you refere me to a good site where i can get more 
> information 
> on writing loops?
> 
> Thank you!
> 
> Kelly
> 
> _________________________________________________________________
> Don’t just search. Find. Check out the new MSN Search! 
> http://search.msn.click-url.com/go/onm00200636ave/direct/01/
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index