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

st: re: macro variables


From   Christopher F Baum <[email protected]>
To   [email protected]
Subject   st: re: macro variables
Date   Wed, 29 Dec 2004 11:19:20 -0500

Cameron said

I tried the following (and a
number of other things):

generate fyed = mdy(12,31,year)
forvalues i = 1/11 {
        if `i' <= 5 local yy = year - 1
        else local yy = year
        replace fyed = mdy(`i'+1,1,`yy') - 1 if fyr == `i'
}


I think this should work:

clear
set obs 100
g year= 1901+_n
g fyr = int(12*uniform())+1
g fyed = mdy(12,31,year)
replace fyed = mdy(fyr+1,1,cond(fyr<5,year-1,year)) if fyr<12
format fyed %td


Kit Baum, Boston College Economics      [email protected]
http://ideas.repec.org/e/pba1.html

*
*   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