PING
0.9
Statistical data handling and processing in production environment
|
Count the number of observations in a dataset, possibly missing or non missing for a given variable.
dsn
: a dataset;miss
: (option) the name of variable/field in the dataset for which only missing observations are considered; default: miss
is not set;nonmiss
: (option) the names of variable/field in the dataset for which only NON missing observations are considered; this is obviously compatible with the miss
argument above only when the variables differ; default: nonmiss
is not set;distinct
: (option) boolean flag (yes/no
) set to count only distinct values; in practice, runs a SQL SELECT DISTINCT
process instead of a simple SELECT
; default: no
, i.e. all values are counted;lib
: (option) name of the input library; by default: WORK
is used._nobs_
: name of the macro variable used to store the result number of observations; by default (i.e., when neither miss nor nonmiss is set, the total number of observations is returned).
Let us consider the table _dstest28
:
geo | value |
---|---|
' ' | 1 |
AT | . |
BG | 2 |
'' | 3 |
FR | . |
IT | 5 |
then we can compute the TOTAL number of observations in _dstest28
:
returns nobs=6
, while:
returns the number of observations with NON MISSING value
, i.e. nobs=4
, and:
returns the number of observations with MISSING value
and NON MISSING geo
at the same time, i.e. nobs=1
.
Run macro %_example_ds_count
for more examples.
with where
defined, when both miss
and nonmiss
parameters are passed for instance, as the SAS expression &miss is missing and not(&nonmiss is missing)
.
provides with a result equivalent to simply launching:
and comparing the values of c0
and c1
: