2.3.2 Datasets containing event information
In addition to retrieving information measured at selected dates, users may also make calculations based on events over time. E.g. one may be interested in finding individuals who got married, became unemployed, or who were unemployed for over 6 months during a given time-span. The command import-event
can be used for this purpose. It performs a variable import where all records (= events) per unit (= individual) are retrieved over a specified time span. In addition to the variable name, two time-points are required in the expression: Start- and stop-date. All events that have happened between the two dates will be retrieved to your dataset, i.e. all events that overlap the time-interval. The dataset will contain a varying number of records per unit (individual) depending on how frequent change-events have occured.
Note that it is only possible to import one event-organized variable into a given dataset. One must therefore create separate datasets for each event-organized variable one needs to work with. It is still possible to connect variables with fixed information, such as e.g. gender, country of birth, date of birth or unit identifiers (personal ID etc.), using the merge
command. This makes it possible to aggregate an event dataset up to a unit dataset using the collapse()
command.
The import is done in the following way:
create-dataset <dataset>
import-event <variable> <start date> to <stop date> as <alias>
Example: Data matrix using import-event (time interval: 2000-01-01 - 2003-01-01)
ID | Start | Stop | Variable |
---|---|---|---|
123456 | 2000-01-01 | 2000-05-30 | 1 |
123456 | 2000-05-31 | 2001-12-31 | 4 |
123456 | 2002-01-01 | 2003-08-15 | 2 |
135791 | 2000-04-10 | 2002-03-03 | 2 |
135791 | 2002-03-04 | 2002-11-11 | 3 |
147036 | 2002-02-28 | 2004-07-16 | 1 |
Note: All events overlapping the time-period 2000-01-01 - 2003-01-01 are retrieved