On Thu, 13 Jun 2013, Summers, Peter wrote:
Hi folks,
I'm trying to generate a matrix of "dates" that I can use on the x-axis
of graphs of forecasts. I want the format to be "yyyy.q" or "yyyy.mm"
for quarterly or monthly data, respectively. Things work fine for
quarterly data, but something weird happens with monthly data.
I create a string with the desired format, then make the corresponding
matrix entry using string substitution. So for example the string
"2009.04" should just become the "number" 2009.04. However, the
string
substitution results in the second "decimal" being truncated, so I get
2009.0 instead of 2009.04, or 2009.1 instead of 2009.12.
The attached script illustrates the problem.
Thanks in advance for any advice!
PS
Your script seems to run fine here; or am I missing something?
<output>
? sscanf(begdate, "%d:%d", tyr, tmo)
? tyr
2009
? tmo
4
? sprintf ss "%d.%d", tyr, tmo
? ss
2009.4
? jnk = @ss
Replaced scalar jnk = 2009.4
? jnk
2009.4
? sprintf ss "%d.0%d", tyr, tmo
? ss
2009.04
? jnk = @ss
Replaced scalar jnk = 2009.04
? jnk
2009.04
? tmo = 12
Replaced scalar tmo = 12
? sprintf ss "%d.%d", tyr, tmo
? ss
2009.12
? jnk = @ss
Replaced scalar jnk = 2009.12
? jnk
2009.12
</output>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------