Lapis Lazuli | Level 10

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

Hi All,

Why nm2=1 in my output?

Thanks!

data check;

input v1-v5 ;

cards;

1 2 3 4 5

;

run;

data look;

set check;

nm1=nmiss(of v1-v5);

nm2=nmiss(of _numeric_);

run;

proc print;run;

Obs    v1    v2    v3    v4    v5    nm1    nm2

1      1     2     3     4     5     0      1

1 ACCEPTED SOLUTION

Accepted Solutions
Opal | Level 21

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

I don't think put statements will explain it for you.  Possibly the following will:

data check;

input v1-v5 ;

cards;

1 2 3 4 5

5 4 3 2 1

;

run;

data look;

set check;

v6=nmiss(of v1-v7);

v7=nmiss(of _numeric_);

run;

proc print;run;

A nice explanation of what gets added to the PDV, and when, can be found at: http://www.lexjansen.com/nesug/nesug88/sas_supervisor.pdf

10 REPLIES 10
Super User

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

See what you get if you reverse the order of the two assignment statements.

Also try putting this statement at a few places in your data step.

put (_numeric_) (=);

Lapis Lazuli | Level 10

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

Thank you Tom!

this is what I got after making changes as you suggested:

data check;

input v1-v5 ;

cards;

1 2 3 4 5

;

run;

data look;

set check;

put (_numeric_) (=);

nm2=nmiss(of _numeric_);

put (_numeric_) (=);

nm1=nmiss(of v1-v5);

put (_numeric_) (=);

run;

proc print;run;

Obs    v1    v2    v3    v4    v5    nm2    nm1

1      1     2     3     4     5     1      0

From log file:

301  data check;

302  input v1-v5 ;

303  cards;

NOTE: The data set WORK.CHECK has 1 observations and 5 variables.

NOTE: DATA statement used (Total process time):

real time           0.00 seconds

cpu time            0.00 seconds

305  ;

306  run;

307

308  data look;

309    set check;

310    put (_numeric_) (=);

311    nm2=nmiss(of _numeric_);

312    put (_numeric_) (=);

313    nm1=nmiss(of v1-v5);

314    put (_numeric_) (=);

315  run;

v1=1 v2=2 v3=3 v4=4 v5=5

v1=1 v2=2 v3=3 v4=4 v5=5 nm2=1

v1=1 v2=2 v3=3 v4=4 v5=5 nm2=1 nm1=0

NOTE: There were 1 observations read from the data set WORK.CHECK.

NOTE: The data set WORK.LOOK has 1 observations and 7 variables.

NOTE: DATA statement used (Total process time):

real time           0.00 seconds

cpu time            0.00 seconds

316  proc print;run;

NOTE: There were 1 observations read from the data set WORK.LOOK.

NOTE: PROCEDURE PRINT used (Total process time):

real time           0.00 seconds

cpu time            0.00 seconds

Opal | Level 21

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

I don't think put statements will explain it for you.  Possibly the following will:

data check;

input v1-v5 ;

cards;

1 2 3 4 5

5 4 3 2 1

;

run;

data look;

set check;

v6=nmiss(of v1-v7);

v7=nmiss(of _numeric_);

run;

proc print;run;

A nice explanation of what gets added to the PDV, and when, can be found at: http://www.lexjansen.com/nesug/nesug88/sas_supervisor.pdf

Opal | Level 21

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

I would think that nm2 is both a numeric variable and is missing at the time the function is applied.

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

nm2=nmiss(of _numeric_);

NM2 is included in the list _NUMERIC_ as it is created and added to the PDV before the list for NMISS(of _NUMERIC_) is evaluated by the compiler.

Lapis Lazuli | Level 10

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

Thank you Art and DN!

Linlin

Quartz | Level 8

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

Here's a variation using CATS rather than NMISS.

data check ;

input v1 - v5 ;

cards ;

1 2 3 4 5

;

data look ;

set check ;

cats1 = cats(of v1 - v5  ) ;

cats2 = cats(of _numeric_) ;

run ;

Both new variables receive the value 12345, but CATS1 is character while CATS2 is numeric. I explain in my SESUG paper

Using SAS® Variable Lists Effectively (pp. 14-15).

Opal | Level 21

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

Howard,  Thanks!  I learned at least one new thing from your paper.  I had never seen numeric and character used in the way you showed in your paper, i.e.:

proc print data=sashelp.class;

var name-numeric-weight;

run;

Super User

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

It is very intesting.

Actually cats2 = cats(of _numeric_) ; is the same with

cats2 = input(cats(of v1-v5) ,best.);

Ksharp

Lapis Lazuli | Level 10

## Why nmiss(of _numeric_) eq 1 when there is no missing value?

Hi Mr. Schreier,

I just finished reading your paper. It is a very good paper.  Thanks - Linlin

Discussion stats
• 10 replies
• 2213 views
• 6 likes
• 6 in conversation