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

st: RE: 2k problem in forvalues


From   "Jiang, Tao" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: 2k problem in forvalues
Date   Wed, 27 Nov 2002 11:21:53 -0500

I tried something on foreach, and I don't see why it doesn't work.

Eg:
. foreach j in 99 00 01 {
  2. di "`j'"
  3. }
99
00
01

. foreach j in 99 00 01 {
  2. su _y`j'
  3. }

    Variable |     Obs        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------
        _y99 |       0

    Variable |     Obs        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------
        _y00 |       0

    Variable |     Obs        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------
        _y01 |       0

(I have all _y99 _y00 _y01 as missing values)


-----Original Message-----
From: Hans J. Baumgartner [mailto:[email protected]]
Sent: Wednesday, November 27, 2002 10:44 AM
To: statalist
Subject: st: 2k problem in forvalues


I would like to use -forvalues- to run loops over the years 84-02. It 
works fine from 84-99 but in 2000 I get problems. I have tried to run 
the loop 00-02 separately to avoid the "2k flip". The thing is, however 
that –foreach- and forvalues- writes 00 as 0 and 01 as 1.

Any suggestions on this?
Hans

-- 
Hans J. Baumgartner 
Deutsches Institut für Wirtschaftsforschung (DIW Berlin)
German Institute for Economic Research
Abt. Staat / Dept. Public Economics
Königin-Luise-Str. 5; 14195 Berlin (Dahlem) 
Tel.: 030/89789-307; Fax.: 030/89789-114
http://www.diw.de


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index