Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: strange global macros


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: strange global macros
Date   Wed, 23 Apr 2008 11:20:48 -0400

. di 20080421
20080421

. di float(20080421)
20080420

See
help data_types
and note that if date_cohort were double or long you would face no
precision problem.



On Wed, Apr 23, 2008 at 11:09 AM, Gabi Huiber <[email protected]> wrote:
> I am having some trouble getting global macros to represent numbers properly.
>
> Every week I receive some csv files that are named things like file_20080331.csv
>
> I use these files in a series of do-files that reference them as
> file_${t}.csv, and all is well.
>
> However, when at the very end I produce a rolling summary report file
> where I want to record the date in the same format, I am getting a
> surprise result. I am doing this:
>
> [...]
> local lastline=${cycles}+1
> set obs `lastline'
> replace date_cohort=${t} in `lastline'
> [...]
>
> Yet the date_cohort observation corresponding to ${t}=20080331 is
> 20080332; and the one that corresponds to ${t}=20080421 is 20080420.
>
> It's strange, because if ${t} were anything but 20080421, my do-files
> would produce a "file not found" error when trying to look for that
> day's csv file. So I am sure that ${t} stores the correct value. What
> I am not sure of is why it is rendering it with a day off in either
> direction.
>
> Can anybody help?
>
> Thank you,
>
> Gabi
> *
*
*   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