DATA Step, Macro, Functions and more

need a macro that checks missing values in the input file

Reply
N/A
Posts: 0

need a macro that checks missing values in the input file

hi is there any macro that checks the missing vlaues in the sas file for n number of variables and if found it sends a mail...
Valued Guide
Posts: 2,177

Re: need a macro that checks missing values in the input file

Posted in reply to deleted_user
in "filename email" online help, you'll find an example,
The easy way to count columns missing in one observation (old forum discussion) http://support.sas.com/forums/thread.jspa?messageID=31443#31443
or similarly[pre] cols_missing = nmiss( of _numeric_,1 ) + cmiss( of _character_, 'a' ) ;[/pre] but that cmiss() is a new function in SAS9.2
Do you need a SAS91 alternative?
Super Contributor
Super Contributor
Posts: 3,174

Re: need a macro that checks missing values in the input file

Regarding conditional EMAILs, there is no pre-coded "macro" to perform the process, however this topic has been discussed in the forum - suggest a search of the forums.

Also, the SAS support http://support.sas.com/ website has SAS-hosted and supplemental technical / conference reference material on this topic/post.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic/post:

conditional email site:sas.com
PROC Star
Posts: 7,467

Re: need a macro that checks missing values in the input file

Posted in reply to deleted_user
If you can use Peter's suggested code you can easily incorporate it within the examples shown at: http://www2.sas.com/proceedings/sugi29/126-29.pdf

HTH,
Art
Valued Guide
Posts: 2,177

Re: need a macro that checks missing values in the input file

just been trying out that suggestion I made and find I would like to update it
cols_missing = nmiss( of _numeric_,1 ) + cmiss( of _character_, 'a' ) ;
returns 1 if the only missing value is in the cols_missing result !
So now I'm suggesting[pre] cols_missing = 0 ; * ensure this is not missing ;
cols_missing = nmiss( of _numeric_,1 ) + cmiss( of _character_, 'a' ) ;[pre]

peterC
Respected Advisor
Posts: 3,799

Re: need a macro that checks missing values in the input file

cols_missing will be part of the _NUMERIC_ list. Is that ok?

It may be "safer" to create two arrays

[pre]
set ...;
array _c
  • _character_;
    array _n
  • _numeric_;
    cols_missing=0;
    cols_missing = nmiss(of _n
  • ,1 ) + cmiss(of _c
  • 'a' );
    [/pre]
  • Valued Guide
    Posts: 2,177

    Re: need a macro that checks missing values in the input file

    Posted in reply to data_null__
    Why is it safer if you are still using _character_ and _numeric_ to define the arrays? Would the array definition create syntax error when there are no character variables?
    I tested my code and that is why the initialisation of col
    _missing to zero was proposed.
    Respected Advisor
    Posts: 3,799

    Re: need a macro that checks missing values in the input file

    Yes I realize now that you have corrected the bug with the initialization of COL_MISSING.

    The safer part I was referring to has to do with where the program uses _NUMERIC_, just after SET before anything else, like defining other numeric variables happen. I often use [pre]IF 0 THEN SET;[/pre] if my program to isolate the variables when creating the ARRAYS.

    It is a common mistake to see _NUMERIC_ used on the left side of an expression as you did, we don't usually remember that the variable on the left COL_MISSING is also included in the list described by _NUMERIC_.

    For me creating the array just after the set as in my example frees me of the having to remember that the variables in _NUMERIC_ may change as I write new statements.
    Ask a Question
    Discussion stats
    • 7 replies
    • 123 views
    • 0 likes
    • 5 in conversation