I have a number of data files which I would like to process with a gretl script. Each file contains a set of annual figures,
e.g.
year, total
1956, 1639
1957, 790
1958, 1150
1959, 909
1960, 1241
When the above sample data is loaded gretl reports:
parsing sample.txt...
using delimiter ','
longest line: 12 characters
first field: 'year'
seems to be observation label
number of columns = 2
number of variables: 1
number of non-blank lines: 6
scanning for variable names...
line: year,total
scanning for row labels and data...
first row label "1956", last label "1960"
trying to parse row labels as dates...
1956: probably a year... and just a year
taking date information from row labels
How can I access the 'first row label' and 'last label' within a script?
given your data set, gretl already recognizes it as a time-series data set with 5 period observations. Printing the initial and last observation label is quite simple.
The
obslabel()
function converts the observation number into a date string (depending on the underlying observation frequency).Furthermore,
$t1
and$t2
are accessors, returning the observation period (integer value) of the initial observation and the last observation, respectively, of the currently selected sample. The accessor$tmax
returns the observation number of the last observation of the overall data set.Accessing the 'first row label' and 'last label' can be done by:
Returns: