Statalist


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

st: strange global macros


From   "Gabi Huiber" <ghuiber@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: strange global macros
Date   Wed, 23 Apr 2008 11:09:22 -0400

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