On Tue, 9 Dec 2014, Logan Kelly wrote:
Actual I am trying to force quarterly data into monthly data set (I
want to leave missing observations). This works
nulldata 8
setobs 4 2012:01
string frequency = "q"
join "gretl_tmp_3785.csv" out --tkey="obs,%Y@frequency%@frequency"
--aggr="avg" --data="ENU2705340010"
but this does not
nulldata 24
setobs 12 2012:01
string frequency = "q"
join "gretl_tmp_3785.csv" out --tkey="obs,%Y@frequency%@frequency"
--aggr="avg" --data="ENU2705340010"
So I am making a silly mistake.
Well, not really. Simply, "join" is not set up for adding time-series
data of lower frequency to an existing dataset of higher frequency
automatically. To use join for this purpose you'd have to supply some
specific key variables. For example:
<hansl>
nulldata 24
setobs 12 2012:01
series year = $obsmajor
series quarter = 1+floor(($obsminor-1)/3)
</hansl>
Then if you have a data file that looks like this
year, quarter, ENU2705340010
2013, 4, 1209
2013, 3, 1163
2013, 2, 1142
2013, 1, 1276
2012, 4, 1239
2012, 3, 1135
2012, 2, 1123
2012, 1, 1278
you can do:
join filename.csv out --ikey=year,quarter --data="ENU2705340010"
This will write the given quarter's data into each month of the
quarter.
An alternative approach is to read the quarterly data into gretl
first, expand the data using "dataset expand" (with either repetition
of values or interpolation), store the expanded (now monthly) data,
then use join.
Note that in your second example above, --aggr=avg is not going to do
anything. The --aggr option applies when n > 1 values from the outer
data file match a single row on the left. Your case is one where a
single row in the outer data file matches more than one slot on the
left. Join provides no special option for dealing with this case, it
just copies the right-hand value into all matching locations on the
left.
Allin Cottrell