![]() |
PING
0.9
Statistical data handling and processing in production environment
|
Conditionally append reference datasets to a master dataset using multiple occurences of PROC APPEND.
dsn : input master dataset;idsn : (list of) input reference dataset(s) to append to the master dataset;drop : (option) list of variable(s) present in the input master dataset to be removed from the final output dataset; default: drop=, no variable is dropped;ikeep : (option) list of variable(s) present in the input reference dataset(s) to be kept in the final dataset; note the use of the predefined flag _ALL_ so that a variable present in any of the idsn will be kept; default: ikeep=, i.e. only the variables present in dsn (and not listed in drop) are kept;cond: (option) where condition/filter to apply on the master dataset; default: cond=, i.e. no filtering is applied;icond: (option) where condition/filter to apply on (all) the input reference dataset(s); default: icond=, i.e. no filtering is applied;lib : (option) name of the library with (all) reference dataset(s); default: lib=WORK;ilib : (option) name of the library with master dataset; default: ilib=WORK.The table dsn is updated using datasets in idsn.
Let us consider test dataset #32 in WORKing library:
| geo | value |
|---|---|
| BE | 0 |
| AT | 0.1 |
| BG | 0.2 |
| LU | 0.3 |
| FR | 0.4 |
| IT | 0.5 |
and update it using test dataset #33:
| geo | value |
|---|---|
| BE | 1 |
| AT | . |
| BG | 2 |
| LU | 3 |
| FR | . |
| IT | 4 |
For that purpose, we can run for the macro %ds_append using the drop, icond and ocond options as follows:
so as to reset _dstest32 to the table:
| geo | value |
|---|---|
| AT | 0.1 |
| BG | 0.2 |
| LU | 0.3 |
| FR | 0.4 |
| IT | 0.5 |
| BE | 1 |
drop and cond are set:ikeep, the macro %ds_append may process several occurrences of the PROC APPEND procedure like this: when ikeep=, otherwise it consists in a DATA step similar to this:
n-replicates of the same table, e.g. running something like: so as to append to dsn a number n=3 of copies of itself, you should instead consider to copy beforehand the table into another dataset to be used as input reference. Otherwise, you will create, owing to the do loop above, a table with (2^n-1) replicates instead, i.e. if you will append to dsn (2^3-1)=7 copies of itself in the case above.
0. SAS institute: "Combining SAS datasets: Methods".