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

st: Generate variable


From   "kelly johnson" <[email protected]>
To   [email protected]
Subject   st: Generate variable
Date   Sun, 08 May 2005 21:46:03 -0400

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/




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