Statalist


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

Re: st: strange global macros


From   "Sergiy Radyakin" <serjradyakin@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: strange global macros
Date   Wed, 23 Apr 2008 12:22:14 -0400

As the help file says "floats have about 7 digits of accuracy". More
precisely the trouble starts for numbers larger than 256^3 (three
bytes) (which equals 16777216) since floats have that much space to
hold the value.

 forvalues i=1/30000000 {
   if `i'!=float(`i') di `i'
 }

16777217
16777219
16777221
16777223
16777225
...

Best regards, Sergiy

On 4/23/08, Gabi Huiber <ghuiber@gmail.com> 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/
>
*
*   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