Home Forums Main Forums SAS Forum MISSING() function, MISSING option/statement and Call Missing() rountine

  • MISSING() function, MISSING option/statement and Call Missing() rountine

     Justin updated 7 months, 1 week ago 1 Member · 2 Posts
  • Justin

    Administrator
    February 7, 2021 at 4:31 pm

    CALL MISSING Routine

    Assigns missing values to the specified character
    or numeric variables.

    Syntax
    CALL MISSING(variable-name-1 <, variable-name-2, …>);

    Required Argument
    variable-name

    specifies the name of SAS character or numeric variables.

    Details
    The CALL MISSING routine assigns an ordinary numeric missing value (.) to each numeric variable in the argument list.

    The CALL MISSING routine assigns a character missing value (a blank) to each character variable in the argument list. If the current length of the character variable equals the maximum length, the current length is not changed. Otherwise, the current length is set to 1.

    You can mix character and numeric variables in the argument list.

    Comparisons
    The MISSING function checks whether the argument has a missing value but does not change the value of the argument.

    data one;
    prod='shoes';
    invty=7498;
    sales=23759;
    call missing(prod, invty);
    put prod= invty= sales=;
    run;
    data one;
    prod='shoes';
    invty=7498;
    sales=23759;
    call missing(of _all_ );
    put prod= invty= sales=;
    run;

    The above code set the specified variables to missing values, including both numeric and char variables.

    • This reply was modified 7 months, 1 week ago by  Justin.
  • Justin

    Administrator
    February 7, 2021 at 4:23 pm

    MISSING() function:
    It is used to check if the value of a variable is null or missing, it can apply to both numeric and character variables. We know, in SAS, we use “.” for the missing values in numeric variables, and blank for character variables. However, you can go ahead to use MISSING() any variable, do NOT need to think about the data type at all. In addition, if your data contains special missing values, you must use MISSING function, because other methods cannot identify them at all.

    MISSING= System Option
    Specifies the character to print for missing numeric values.
    Syntax
    MISSING=<‘>character<‘>

    Syntax Description
    character

    specifies the value to be printed. The value can be any character such as ‘/’, ‘-‘, ‘ ‘, ‘0’ etc. Single or double quotation marks are optional. Please note: the MISSING= system option does not apply to special missing values such as .A and .Z.

    MISSING Statement
    Assigns characters in your input data to represent special missing values for numeric data.
    Valid: anywhere
    Details
    The MISSING statement usually appears within a DATA step, but it is global in scope.
    Comparisons
    The MISSING= system option allows you to specify a character to be printed when numeric variables contain ordinary missing values (.). If your data contain characters that represent special missing values, such as a or z , do not use the MISSING= option to define them; simply define these values in
    a MISSING statement.

    Examples
    With survey data, you might want to identify certain types of missing data. For example, in the data, an A can mean that the respondent is not at home at the time of the survey; an R can mean that the respondent refused to answer. Use the MISSING statement to identify to SAS that the values A and R
    in the input data lines are to be considered special missing values rather than invalid numeric data values:

     data survey;
    missing a r;
    input id answer;
    datalines;
    001 2
    002 R
    003 1
    004 A
    005 2
    ;
    run;

    The resulting data set SURVEY contains exactly the values that are coded in the input data.

    The following example uses data from a marketing research company. Five testers were hired to test five different products for ease of use and effectiveness. If a tester was absent, there is no rating to report, and the value is recorded with an X for “absent.” If the tester was unable to test the product adequately, there is no rating, and the value is recorded with an I for “incomplete test.” The following program reads the data and displays the resulting SAS data set. Note the special missing values in the first and third data lines:

     data period_a;
    missing X I;
    input Id $4. Foodpr1 Foodpr2 Foodpr3 Coffeem1 Coffeem2;
    datalines;
    1001 115 45 65 I 78
    1002 86 27 55 72 86
    1004 93 52 X 76 88
    1015 73 35 43 112 108
    1027 101 127 39 76 79
    ;
    run;
    proc print data=period_a;
    title 'Results of Test Period A';
    footnote1 'X indicates TESTER ABSENT';
    footnote2 'I indicates TEST WAS INCOMPLETE';
    run;

    • This discussion was modified 7 months, 1 week ago by  Justin.
    • This discussion was modified 7 months, 1 week ago by  Justin.

Log in to reply.

Original Post
0 of 0 posts June 2018
Now