![]() |
PING
0.9
Statistical data handling and processing in production environment
|
Extract the values of a given variable in a dataset into an unformatted (i.e., unquoted and blank-separated) list.
dsn : a dataset reference;var : either a field name, or the position of a field name in, in &dsn, whose values (observations) will be converted into a list;distinct : (option) boolean flag (yes/no) set to return in the list only distinct values from &var variable; in practice, runs a SQL SELECT DISTINCT process prior to the values' extraction; default: distinct=NO, i.e. all values are returned;sep : (option) character/string separator in output list; default: %str( ), i.e. sep is blank;where : (option) SAS expression used to further refine the selection (WHERE option); should be passed with %str; default: empty;na_rm : (option) boolean flag (yes/no) set to remove missing (NA) values from the observations; default: na_rm=YES, therefore all missing (. or ' ') values will be discarded in the output list;lib : (option) output library; default: lib is set to WORK._varlst_ : name of the macro variable used to store the output list, i.e. the (blank separated) list of (possibly non-missing) observations in &var.
Let us consider the test dataset #28 as dsn:
| geo | value |
|---|---|
| AT | 1 |
| '' | . |
| BG | 2 |
| '' | 3 |
| FR | . |
| IT | 4 |
then the following call to the macro:
will both return: ctry=AT BG FR IT, while:
will return: val=1 2 3 4, and:
will both return: val=1 . 2 3 . 4.
Run macro %_example_var_to_list for more examples.
distinct=YES, and na_rm=YES:na_rm=NO), an empty list is returned.