I am working in SAS Enterprise guide on a line of code that is supposed to read the number of observations in a dataset. The dataset contains 3 rows (observations).
I write the following line of code to get the number of observations and store it in the number_observations
variable:
call symputx("number_observations", put(attrn(dsid, "nobs"),best.));
However, instead of getting a result of 3
, this line returns 9
for me
Any idea what is happening? I should maybe also note that I manually edited this table (it used to have 9 rows).
Use nlobs
instead of nobs
. nlobs
gives the number of logical observations, honoring any records marked for deletion.
There are some situations where nlobs will return -1 if it doesn't know the number of observations. My favorite countobs paper is http://www2.sas.com/proceedings/sugi26/p095-26.pdf.