![]() |
PING
0.9
Statistical data handling and processing in production environment
|
Retrieve the list (possibly ordered by varnum) of variables/fields in a given dataset.
dsn1 dsn1: two datasets reference (request);lib1 : input(option) library for dsn1 dataset;lib2 : input (option) library for dsn2 dataset;ans : the boolean result of the comparison test of the "sets" associated to the input lists, i.e.:
0 when two datasets are equal: dsn1 = dsn2,1 when dsn1has less variables then dsb2,Consider the test dataset #5:
| f | e | d | c | b | a |
|---|---|---|---|---|---|
| . | 1 | 2 | 3 | . | 5 |
One can retrieve the ordered list of variables in the dataset with the command:
%let list=; %ds_compare(_dstest5, _varlst_=list);
which returns list=f e d c b a, while:
%ds_compare(_dstest5, _varlst_=list, varnum=no);
returns list=a b c d e f. Similarly, we can also run it on our database, e.g.:
libname rdb "&G_PING_C_RDB"; %let lens=; %let typs=; %ds_compare(PEPS01, _varlst_=list, _typlst_=typs, _lenlst_=lens, lib=rdb);
returns:
list=geo time age sex unit ivalue iflag unrel n ntot totwgh lastup lastuser,typs= 2 1 2 2 2 1 2 1 1 1 1 2 2,lens= 5 8 13 3 13 8 1 8 8 8 8 7 7.Another useful use: we can retrieve data of interest from existing tables, e.g. the list of geographical zones in the EU:
%let zones=; %ds_compare(&G_PING_COUNTRYxZONE, _varlst_=zones, lib=&G_PING_LIBCFG); %let zones=%list_slice(&zones, ibeg=2);
which will return: zones=EA EA12 EA13 EA16 EA17 EA18 EA19 EEA EEA18 EEA28 EEA30 EU15 EU25 EU27 EU28 EFTA EU07 EU09 EU10 EU12.
Run macro %_example_ds_compare for more examples.
In short, the program runs (when varnum=yes):
PROC CONTENTS DATA = &dsn
OUT = tmp(keep = name type length varnum);
run;
PROC SORT DATA = tmp
OUT = &tmp(keep = name type length);
BY varnum;
run;
and retrieves the resulting name, type and length variables.
Compare two datasets.
dsn1 dsn1: two datasets reference (request);lib1 : input(option) library for dsn1 dataset;lib2 : input (option) library for dsn2 dataset;ans : the boolean result of the comparison test of the "sets" associated to the input lists, i.e.:
0 when two datasets are equal: dsn1 = dsn2,1 when dsn1has less variables then dsb2,Consider the test dataset #5:
| f | e | d | c | b | a |
|---|---|---|---|---|---|
| . | 1 | 2 | 3 | . | 5 |
One can retrieve the ordered list of variables in the dataset with the command:
which returns list=f e d c b a, while:
returns list=a b c d e f. Similarly, we can also run it on our database, e.g.:
returns:
list=geo time age sex unit ivalue iflag unrel n ntot totwgh lastup lastuser,typs= 2 1 2 2 2 1 2 1 1 1 1 2 2,lens= 5 8 13 3 13 8 1 8 8 8 8 7 7.Another useful use: we can retrieve data of interest from existing tables, e.g. the list of geographical zones in the EU:
which will return: zones=EA EA12 EA13 EA16 EA17 EA18 EA19 EEA EEA18 EEA28 EEA30 EU15 EU25 EU27 EU28 EFTA EU07 EU09 EU10 EU12.
Run macro %_example_ds_compare for more examples.
In short, the program runs (when varnum=yes):
and retrieves the resulting name, type and length variables.