On Mon, 17 Sep 2012, Ignacio Diaz-Emparanza wrote: > A different possibility is to play with strings. We have the command > 'obslabel' for this. > For example, if the observations are quarterly, this code writes the > year of the 't' observation into the string 'iyear' and the quarter into > the string 'iquarter': (where t=1, 2, 3, ... is the 1-based index of the > observation: ) > > <hansl> > string s = obslabel(t) > sscanf s, "%d:%d", tyear, tquarter > </hansl> > > If you need it, you may then put the strings in scalars in this way: > > scalar ty=@tyear > scalar tq=@tquarter
Hmm, the "%d" conversion already produces a scalar. 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> Allin Cottrell