PING
0.9
Statistical data handling and processing in production environment
|
Conditionally delete observations and drop variable(s) from a given dataset.
dsn
: a dataset reference;var
: (option) List of variable(s) to delete (drop
) from the dataset; if more variables are to be deleted, var
should be defined as an unformatted list; default: not used;cond
: (option) an expression that resolves to a boolean (0/1) so that all observations for which cond
is true (1) will be deleted; default: 0
, i.e. no observations is deleted;firstobs, obs
: (option) indexes of the first and the last observations to consider for the delete operation resp.; all obsevation whose index is <firstobs
or >obs
will be automatically deleted; see DATA
step options; by default, options are not used;lib
: (option) name of the input library; by default: empty, i.e. WORK
is used.The table dsn
is updated with the conditional deletion.
Let us consider the following _dstest31
table:
geo | value | unit |
---|---|---|
BE | 0 | EUR |
AT | 0.1 | EUR |
BG | 0.2 | NAC |
LU | 0.3 | EUR |
FR | 0.4 | NAC |
IT | 0.5 | EUR |
we will delete all VALUEs and keep only observations for which UNIT is EUR:
so that we have:
geo | unit |
---|---|
BG | NAC |
FR | NAC |
Note that the command can be used to delete more than one variable at a time, e.g.:
will return instead:
geo |
---|
BG |
FR |
Run macro %_example_ds_delete
for more examples.
DATA
step:firstobs
and obs
are applied, then the condition cond
is evaluated (though it occurs inside a unique DATA
step), and then the variable var
is dropped from the dataset. This matters in the cases where cond
is an expression based on var
values.