BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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...
7 REPLIES 7
Peter_C
Rhodochrosite | Level 12
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?
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
art297
Opal | Level 21
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
Peter_C
Rhodochrosite | Level 12
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
data_null__
Jade | Level 19
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]
  • Peter_C
    Rhodochrosite | Level 12
    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.
    data_null__
    Jade | Level 19
    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.

    sas-innovate-2024.png

    Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

    Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

     

    Register now!

    How to Concatenate Values

    Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

    Find more tutorials on the SAS Users YouTube channel.

    Click image to register for webinarClick image to register for webinar

    Classroom Training Available!

    Select SAS Training centers are offering in-person courses. View upcoming courses for:

    View all other training opportunities.

    Discussion stats
    • 7 replies
    • 736 views
    • 0 likes
    • 5 in conversation