On Mon, 17 Sep 2012, Allin Cottrell wrote:
If series results are wanted, here's a variant on Ignacio's
suggestion. It's bulkier than Jack's suggestion, but it doesn't
depend on knowing the starting year and quarter in advance:
<hansl>
open data9-7
series quarter year
scalar tyear tquart
string s
loop t=1..$nobs -q
s = obslabel(t)
sscanf s, "%d:%d", tyear, tquart
year[t] = tyear
quarter[t] = tquart
endloop
print year quarter --byobs
</hansl>
Thinking about this, it seemed lame that you had to use temporary
scalar variables to accept the result of scalar conversions from
sscanf -- rather than assigning the results directly to elements of
series (or matrices). That's now fixed: the following nicer version
will work with current CVS:
<hansl>
open data9-7
series quarter year
string s
loop t=1..$nobs -q
s = obslabel(t)
sscanf s, "%d:%d", year[t], quarter[t]
endloop
</hansl>
This will be in the snapshots for Windows and Mac tomorrow.
Allin Cottrell