SAS Missing Values Findings












0















I am working on a SAS Dataset which has missing values.

I can identify whether a particular variable has missing values using IS NULL/IS MISSING operator.

Is there any alternative way, through which I can identify which variables have missing values in one shot.



Thanks in Advance










share|improve this question





























    0















    I am working on a SAS Dataset which has missing values.

    I can identify whether a particular variable has missing values using IS NULL/IS MISSING operator.

    Is there any alternative way, through which I can identify which variables have missing values in one shot.



    Thanks in Advance










    share|improve this question



























      0












      0








      0








      I am working on a SAS Dataset which has missing values.

      I can identify whether a particular variable has missing values using IS NULL/IS MISSING operator.

      Is there any alternative way, through which I can identify which variables have missing values in one shot.



      Thanks in Advance










      share|improve this question
















      I am working on a SAS Dataset which has missing values.

      I can identify whether a particular variable has missing values using IS NULL/IS MISSING operator.

      Is there any alternative way, through which I can identify which variables have missing values in one shot.



      Thanks in Advance







      sas






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '18 at 18:47









      Jérôme Teisseire

      1,0361919




      1,0361919










      asked Nov 24 '18 at 17:47









      Atreyi DattaAtreyi Datta

      1




      1
























          4 Answers
          4






          active

          oldest

          votes


















          2














          The syntax IS NULL or IS MISSING is limited to use in SQL code (also in WHERE statements or WHERE= dataset options since those essentially use the same parser.)



          To test if a value is missing you can also use the MISSING() function. Or compare it to a missing value. So for character variables test if it is equal to all blanks: c=' '. For numeric you can test x=., but you also need to look out for special missing values. So you might test if x <= .z.



          To get a quick summary of number of distinct missing values for each variable you could use the NLEVEL option on PROC FREQ. Note it might not work for a large dataset with too many distinct values as the procedure will run out of memory.






          share|improve this answer































            1














            use array and vname to find variable with missing values. If you want rows with missing values use cmiss function.



            data have;
            infile datalines missover;
            input id num char $ var $;
            datalines;
            1 . A C
            2 3 D
            5 6 B D
            ;



            /* gives variables with missing values*/

            data want1(keep=miss);
            set have;
            array chars(*) _character_;
            array nums(*) _numeric_;

            do i=1 to dim(chars);

            if chars(i)=' ' then
            miss=vname(chars(i));

            if nums(i)=. then
            miss=vname(nums(i));
            end;

            if miss=' ' then
            delete;
            run;

            /* gives rows with missing value*/

            data want(drop=rows);
            set have;
            rows=cmiss(of id -- var);

            if rows=1;
            run;





            share|improve this answer

































              1














              You can use proc freq table statement with missing option. It includes missing category if missing values exist. Useful for categorical data.



              data example;
              input A Freq;
              datalines;
              1 2
              2 2
              . 2
              ;

              *list variables in tables statement;
              proc freq data=example;
              tables A / missing;
              run;


              You can also use Proc Univariate it creates MissingValues table in ODS by default if any missing values exist. Useful for numeric data.






              share|improve this answer































                1














                Two options (in addition to Peter Slezák's) I can suggest are :
                - Use proc means with nmiss



                proc means data = ___ n nmiss;
                var _numeric_;
                run;



                • In SAS Enterprise Guide, there is a characterize data task - this helps profile character variables too. (Under the hood, it is a combination of various procs, but is an easy to use option).


                Hope this helps,
                regards,
                Sundaresh






                share|improve this answer























                  Your Answer






                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "1"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460855%2fsas-missing-values-findings%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  2














                  The syntax IS NULL or IS MISSING is limited to use in SQL code (also in WHERE statements or WHERE= dataset options since those essentially use the same parser.)



                  To test if a value is missing you can also use the MISSING() function. Or compare it to a missing value. So for character variables test if it is equal to all blanks: c=' '. For numeric you can test x=., but you also need to look out for special missing values. So you might test if x <= .z.



                  To get a quick summary of number of distinct missing values for each variable you could use the NLEVEL option on PROC FREQ. Note it might not work for a large dataset with too many distinct values as the procedure will run out of memory.






                  share|improve this answer




























                    2














                    The syntax IS NULL or IS MISSING is limited to use in SQL code (also in WHERE statements or WHERE= dataset options since those essentially use the same parser.)



                    To test if a value is missing you can also use the MISSING() function. Or compare it to a missing value. So for character variables test if it is equal to all blanks: c=' '. For numeric you can test x=., but you also need to look out for special missing values. So you might test if x <= .z.



                    To get a quick summary of number of distinct missing values for each variable you could use the NLEVEL option on PROC FREQ. Note it might not work for a large dataset with too many distinct values as the procedure will run out of memory.






                    share|improve this answer


























                      2












                      2








                      2







                      The syntax IS NULL or IS MISSING is limited to use in SQL code (also in WHERE statements or WHERE= dataset options since those essentially use the same parser.)



                      To test if a value is missing you can also use the MISSING() function. Or compare it to a missing value. So for character variables test if it is equal to all blanks: c=' '. For numeric you can test x=., but you also need to look out for special missing values. So you might test if x <= .z.



                      To get a quick summary of number of distinct missing values for each variable you could use the NLEVEL option on PROC FREQ. Note it might not work for a large dataset with too many distinct values as the procedure will run out of memory.






                      share|improve this answer













                      The syntax IS NULL or IS MISSING is limited to use in SQL code (also in WHERE statements or WHERE= dataset options since those essentially use the same parser.)



                      To test if a value is missing you can also use the MISSING() function. Or compare it to a missing value. So for character variables test if it is equal to all blanks: c=' '. For numeric you can test x=., but you also need to look out for special missing values. So you might test if x <= .z.



                      To get a quick summary of number of distinct missing values for each variable you could use the NLEVEL option on PROC FREQ. Note it might not work for a large dataset with too many distinct values as the procedure will run out of memory.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Nov 24 '18 at 19:13









                      TomTom

                      23.9k2718




                      23.9k2718

























                          1














                          use array and vname to find variable with missing values. If you want rows with missing values use cmiss function.



                          data have;
                          infile datalines missover;
                          input id num char $ var $;
                          datalines;
                          1 . A C
                          2 3 D
                          5 6 B D
                          ;



                          /* gives variables with missing values*/

                          data want1(keep=miss);
                          set have;
                          array chars(*) _character_;
                          array nums(*) _numeric_;

                          do i=1 to dim(chars);

                          if chars(i)=' ' then
                          miss=vname(chars(i));

                          if nums(i)=. then
                          miss=vname(nums(i));
                          end;

                          if miss=' ' then
                          delete;
                          run;

                          /* gives rows with missing value*/

                          data want(drop=rows);
                          set have;
                          rows=cmiss(of id -- var);

                          if rows=1;
                          run;





                          share|improve this answer






























                            1














                            use array and vname to find variable with missing values. If you want rows with missing values use cmiss function.



                            data have;
                            infile datalines missover;
                            input id num char $ var $;
                            datalines;
                            1 . A C
                            2 3 D
                            5 6 B D
                            ;



                            /* gives variables with missing values*/

                            data want1(keep=miss);
                            set have;
                            array chars(*) _character_;
                            array nums(*) _numeric_;

                            do i=1 to dim(chars);

                            if chars(i)=' ' then
                            miss=vname(chars(i));

                            if nums(i)=. then
                            miss=vname(nums(i));
                            end;

                            if miss=' ' then
                            delete;
                            run;

                            /* gives rows with missing value*/

                            data want(drop=rows);
                            set have;
                            rows=cmiss(of id -- var);

                            if rows=1;
                            run;





                            share|improve this answer




























                              1












                              1








                              1







                              use array and vname to find variable with missing values. If you want rows with missing values use cmiss function.



                              data have;
                              infile datalines missover;
                              input id num char $ var $;
                              datalines;
                              1 . A C
                              2 3 D
                              5 6 B D
                              ;



                              /* gives variables with missing values*/

                              data want1(keep=miss);
                              set have;
                              array chars(*) _character_;
                              array nums(*) _numeric_;

                              do i=1 to dim(chars);

                              if chars(i)=' ' then
                              miss=vname(chars(i));

                              if nums(i)=. then
                              miss=vname(nums(i));
                              end;

                              if miss=' ' then
                              delete;
                              run;

                              /* gives rows with missing value*/

                              data want(drop=rows);
                              set have;
                              rows=cmiss(of id -- var);

                              if rows=1;
                              run;





                              share|improve this answer















                              use array and vname to find variable with missing values. If you want rows with missing values use cmiss function.



                              data have;
                              infile datalines missover;
                              input id num char $ var $;
                              datalines;
                              1 . A C
                              2 3 D
                              5 6 B D
                              ;



                              /* gives variables with missing values*/

                              data want1(keep=miss);
                              set have;
                              array chars(*) _character_;
                              array nums(*) _numeric_;

                              do i=1 to dim(chars);

                              if chars(i)=' ' then
                              miss=vname(chars(i));

                              if nums(i)=. then
                              miss=vname(nums(i));
                              end;

                              if miss=' ' then
                              delete;
                              run;

                              /* gives rows with missing value*/

                              data want(drop=rows);
                              set have;
                              rows=cmiss(of id -- var);

                              if rows=1;
                              run;






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Nov 24 '18 at 18:54

























                              answered Nov 24 '18 at 18:42









                              Kiran Kiran

                              2,95531019




                              2,95531019























                                  1














                                  You can use proc freq table statement with missing option. It includes missing category if missing values exist. Useful for categorical data.



                                  data example;
                                  input A Freq;
                                  datalines;
                                  1 2
                                  2 2
                                  . 2
                                  ;

                                  *list variables in tables statement;
                                  proc freq data=example;
                                  tables A / missing;
                                  run;


                                  You can also use Proc Univariate it creates MissingValues table in ODS by default if any missing values exist. Useful for numeric data.






                                  share|improve this answer




























                                    1














                                    You can use proc freq table statement with missing option. It includes missing category if missing values exist. Useful for categorical data.



                                    data example;
                                    input A Freq;
                                    datalines;
                                    1 2
                                    2 2
                                    . 2
                                    ;

                                    *list variables in tables statement;
                                    proc freq data=example;
                                    tables A / missing;
                                    run;


                                    You can also use Proc Univariate it creates MissingValues table in ODS by default if any missing values exist. Useful for numeric data.






                                    share|improve this answer


























                                      1












                                      1








                                      1







                                      You can use proc freq table statement with missing option. It includes missing category if missing values exist. Useful for categorical data.



                                      data example;
                                      input A Freq;
                                      datalines;
                                      1 2
                                      2 2
                                      . 2
                                      ;

                                      *list variables in tables statement;
                                      proc freq data=example;
                                      tables A / missing;
                                      run;


                                      You can also use Proc Univariate it creates MissingValues table in ODS by default if any missing values exist. Useful for numeric data.






                                      share|improve this answer













                                      You can use proc freq table statement with missing option. It includes missing category if missing values exist. Useful for categorical data.



                                      data example;
                                      input A Freq;
                                      datalines;
                                      1 2
                                      2 2
                                      . 2
                                      ;

                                      *list variables in tables statement;
                                      proc freq data=example;
                                      tables A / missing;
                                      run;


                                      You can also use Proc Univariate it creates MissingValues table in ODS by default if any missing values exist. Useful for numeric data.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 26 '18 at 20:21









                                      Peter SlezákPeter Slezák

                                      112




                                      112























                                          1














                                          Two options (in addition to Peter Slezák's) I can suggest are :
                                          - Use proc means with nmiss



                                          proc means data = ___ n nmiss;
                                          var _numeric_;
                                          run;



                                          • In SAS Enterprise Guide, there is a characterize data task - this helps profile character variables too. (Under the hood, it is a combination of various procs, but is an easy to use option).


                                          Hope this helps,
                                          regards,
                                          Sundaresh






                                          share|improve this answer




























                                            1














                                            Two options (in addition to Peter Slezák's) I can suggest are :
                                            - Use proc means with nmiss



                                            proc means data = ___ n nmiss;
                                            var _numeric_;
                                            run;



                                            • In SAS Enterprise Guide, there is a characterize data task - this helps profile character variables too. (Under the hood, it is a combination of various procs, but is an easy to use option).


                                            Hope this helps,
                                            regards,
                                            Sundaresh






                                            share|improve this answer


























                                              1












                                              1








                                              1







                                              Two options (in addition to Peter Slezák's) I can suggest are :
                                              - Use proc means with nmiss



                                              proc means data = ___ n nmiss;
                                              var _numeric_;
                                              run;



                                              • In SAS Enterprise Guide, there is a characterize data task - this helps profile character variables too. (Under the hood, it is a combination of various procs, but is an easy to use option).


                                              Hope this helps,
                                              regards,
                                              Sundaresh






                                              share|improve this answer













                                              Two options (in addition to Peter Slezák's) I can suggest are :
                                              - Use proc means with nmiss



                                              proc means data = ___ n nmiss;
                                              var _numeric_;
                                              run;



                                              • In SAS Enterprise Guide, there is a characterize data task - this helps profile character variables too. (Under the hood, it is a combination of various procs, but is an easy to use option).


                                              Hope this helps,
                                              regards,
                                              Sundaresh







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Nov 26 '18 at 21:56









                                              SundareshSundaresh

                                              213




                                              213






























                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Stack Overflow!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460855%2fsas-missing-values-findings%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  Costa Masnaga

                                                  Fotorealismo

                                                  Sidney Franklin