<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to find out if all the values of a variable (numeric or character) are missing? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931889#M366622</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I used only&amp;nbsp;out=test1, it is not showing all the variables in the dataset. The variables can be seen in the output window, but I was not able to see them in the dataset where I can further process them. To further process them, I need them in the dataset instead in output window.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To find out which file is getting created at the background to store this information (which is available in output window), I used following code with ods trace on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="sas"&gt;&lt;SPAN&gt;&lt;STRONG&gt;ods trace on;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ods output onewayfreqs=xxx;&lt;/STRONG&gt;&lt;BR /&gt;proc freq&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=one; 
&lt;SPAN&gt;format&lt;/SPAN&gt; _CHAR_ $missfmt.; &lt;SPAN&gt;/* apply format for the duration of this PROC */&lt;/SPAN&gt;
tables _CHAR_ / out=test1 &lt;SPAN&gt;missing&lt;/SPAN&gt; missprint nocum nopercent;
&lt;SPAN&gt;run&lt;/SPAN&gt;;&lt;BR /&gt;&lt;STRONG&gt;ods trace off;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;As a result, I can now see the dataset in xxx but it is too complex to comprehend. It can be comprehended but there are other ways like macros to find out. I was thinking if there is any simpler way. I found the above approach simplest but that is not giving me information in dataset but only in output window and when I got the dataset which is creating that output window, it is again too complex.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jun 2024 12:00:11 GMT</pubDate>
    <dc:creator>DrAbhijeetSafai</dc:creator>
    <dc:date>2024-06-12T12:00:11Z</dc:date>
    <item>
      <title>How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931883#M366618</link>
      <description>&lt;P&gt;I have a datasets which have combination of numeric as well as character variables. I would like to know if there is any easy way to find out if 'all' the values of that variable are missing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 11:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931883#M366618</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-06-12T11:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931884#M366619</link>
      <description>&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings20/4737-2020.pdf" target="_blank" rel="noopener"&gt;https://support.sas.com/resources/papers/proceedings20/4737-2020.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Paper written by SAS communities member&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 12:42:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931884#M366619</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-12T12:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931886#M366620</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was also looking at &lt;A href="https://blogs.sas.com/content/iml/2011/09/19/count-the-number-of-missing-values-for-each-variable.html" target="_self"&gt;this&lt;/A&gt;. I found this one simpler. I am just trying to take all the variables out by using out= option in proc freq in the code below. Please look at the out= part which I have bolded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="sas"&gt;&lt;SPAN&gt;/* create a format to group missing and nonmissing */&lt;/SPAN&gt;
proc &lt;SPAN&gt;format&lt;/SPAN&gt;;
 value $missfmt &lt;SPAN&gt;' '&lt;/SPAN&gt;=&lt;SPAN&gt;'Missing'&lt;/SPAN&gt; other=&lt;SPAN&gt;'Not Missing'&lt;/SPAN&gt;;
 value  missfmt  . =&lt;SPAN&gt;'Missing'&lt;/SPAN&gt; other=&lt;SPAN&gt;'Not Missing'&lt;/SPAN&gt;;
&lt;SPAN&gt;run&lt;/SPAN&gt;;
&amp;nbsp;
&lt;SPAN&gt;proc freq&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=one; 
&lt;SPAN&gt;format&lt;/SPAN&gt; _CHAR_ $missfmt.; &lt;SPAN&gt;/* apply format for the duration of this PROC */&lt;/SPAN&gt;
tables _CHAR_ / &lt;STRONG&gt;out=test1&lt;/STRONG&gt; &lt;SPAN&gt;missing&lt;/SPAN&gt; missprint nocum nopercent;
&lt;SPAN&gt;format&lt;/SPAN&gt; &lt;SPAN&gt;_NUMERIC_&lt;/SPAN&gt; missfmt.;
tables &lt;SPAN&gt;_NUMERIC_&lt;/SPAN&gt; / &lt;SPAN&gt;missing&lt;/SPAN&gt; missprint nocum nopercent;
&lt;SPAN&gt;run&lt;/SPAN&gt;;&lt;/PRE&gt;
&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 11:38:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931886#M366620</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-06-12T11:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931888#M366621</link>
      <description>&lt;P&gt;Is there something wrong with the part you have in bold? If so, please explain.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 11:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931888#M366621</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-12T11:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931889#M366622</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I used only&amp;nbsp;out=test1, it is not showing all the variables in the dataset. The variables can be seen in the output window, but I was not able to see them in the dataset where I can further process them. To further process them, I need them in the dataset instead in output window.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To find out which file is getting created at the background to store this information (which is available in output window), I used following code with ods trace on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="sas"&gt;&lt;SPAN&gt;&lt;STRONG&gt;ods trace on;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ods output onewayfreqs=xxx;&lt;/STRONG&gt;&lt;BR /&gt;proc freq&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=one; 
&lt;SPAN&gt;format&lt;/SPAN&gt; _CHAR_ $missfmt.; &lt;SPAN&gt;/* apply format for the duration of this PROC */&lt;/SPAN&gt;
tables _CHAR_ / out=test1 &lt;SPAN&gt;missing&lt;/SPAN&gt; missprint nocum nopercent;
&lt;SPAN&gt;run&lt;/SPAN&gt;;&lt;BR /&gt;&lt;STRONG&gt;ods trace off;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;As a result, I can now see the dataset in xxx but it is too complex to comprehend. It can be comprehended but there are other ways like macros to find out. I was thinking if there is any simpler way. I found the above approach simplest but that is not giving me information in dataset but only in output window and when I got the dataset which is creating that output window, it is again too complex.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 12:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931889#M366622</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-06-12T12:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931890#M366623</link>
      <description>&lt;P&gt;You can take the ONEWAYFREQS output and make it into a manageable/understandable data set. See&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/proc-freq-one-way-table-for-multiple-vars-export-to-data-set/m-p/924730#M363982" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/proc-freq-one-way-table-for-multiple-vars-export-to-data-set/m-p/924730#M363982&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 12:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931890#M366623</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-12T12:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931891#M366624</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was searching some simple way. Thanks for your response but I was thinking if there is any other simple way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 12:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931891#M366624</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-06-12T12:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931892#M366625</link>
      <description>&lt;P&gt;I'm not sure I understand your definition of "simple". The code has been written by others, you just need to plug it into your program, that seems pretty simple to me.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 12:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931892#M366625</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-12T12:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931895#M366626</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/27897"&gt;@DrAbhijeetSafai&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was searching some simple way. Thanks for your response but I was thinking if there is any other simple way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A simple way is to use the NLEVELS output of PROC FREQ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods select none;
ods output nlevels=nlevels;
proc freq data=sashelp.cars nlevels;
  tables _all_ / noprint;
run;
ods select all;

proc print data=nlevels;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1718194710894.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97245i85D40C2B8716E08D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1718194710894.png" alt="Tom_0-1718194710894.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;So to find the variables that have only missing values look for those that have NNonMissLevels=0.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select nliteral(tablevar) into :missvar_list separated by ' '
from nlevels
where nnonmisslevels=0
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are a couple of problems/issues with this method:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The biggest one is that for large datasets with variables that have a lot of distinct values PROC FREQ might not be able to complete the analysis due to lack of memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second is just the nature of using ODS OUTPUT datasets.&amp;nbsp; They are built for DISPLAY and not really as DATA.&amp;nbsp; So which variables appear and how they are defined in the output dataset will depend on what is in the dataset being analyzed.&amp;nbsp; You can fix that by adding a second step that defines a consistent data structure.&amp;nbsp; For example by setting the variable name and label fields to the maximum value that SAS supports for those attributes.&amp;nbsp; And you can remove the unneeded formats that it attaches.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data nlevels;
  length TableVar $32 NLevels NMissLevels NNonMissLevels 8 TableVarLabel $256 ;
  set nlevels;
  format _all_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_1-1718195685082.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97246iAD9E45AB3D537B18/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_1-1718195685082.png" alt="Tom_1-1718195685082.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 12:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931895#M366626</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-06-12T12:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931899#M366627</link>
      <description>&lt;P&gt;If you are using SAS Studio, there is a Describe Missing Data task - the great thing about the Task is will show you patterns of "missingness"&amp;nbsp; (example: VAR1 &amp;amp; VAR2 are missing on X number of observations).&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 12:53:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931899#M366627</guid>
      <dc:creator>tom_grant</dc:creator>
      <dc:date>2024-06-12T12:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931904#M366628</link>
      <description>&lt;P&gt;Using this or similar formats will solve the memory problem.&amp;nbsp; Still kind of slow for really large data sets.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   proc format;
      value $_miss(default=1) ' '=' '   other='X';
      value  _miss(default=1) ._-.z=' ' other='X';
      quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2024 13:38:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931904#M366628</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-06-12T13:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931911#M366629</link>
      <description>&lt;P&gt;You don't need the frequency tables OUT=.&amp;nbsp; All you need is NLEVELS.&amp;nbsp; I believe this is about as simple as it can be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value $_miss(default=1) ' '=' '   other='X';
   value  _miss(default=1) ._-.z=' ' other='X';
   quit;
data class;
   set sashelp.class;
   name = ' '||name;
   allmiss = ' ';
   x = .d;
   run;
proc freq nlevels;
   tables _all_ / noprint;
   format _character_ $_miss. _numeric_ _miss.;
   ods select nlevels;
   ods output nlevels=nlevels;
   run;
data nlevels;
   length TableVar $32 NLevels NMissLevels NNonMissLevels 8;
   set nlevels;
   run;
proc print;
   run;
proc sql noprint;
   select TableVar into :allmissvars separated by ' ' 
      from nlevels where nnonmisslevels eq 0;
   quit;
%put NOTE: &amp;amp;=allmissvars;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 374px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97247iB985A34D55F41D0B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 14:09:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931911#M366629</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-06-12T14:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931919#M366632</link>
      <description>&lt;P&gt;Just for fun:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let size=100;
data have;
  array noMissC[&amp;amp;size.] $1 (&amp;amp;size.*"A");
  array noMissN[&amp;amp;size.]   (&amp;amp;size.*1)  ;
  array   MissC[&amp;amp;size.] $1            ;
  array   MissN[&amp;amp;size.]               ;
  do i = 1 to 5e6;
    output;
  end;
run;
/*
proc print;
run;
*/

options ls=max;

%macro anyNonMissingData(ds);
proc format;
  value missing
    ._-.z = " "
    other = "*"
  ;
  value $missing
    " " = " "
    other = "*"
  ;
run;
data _null_;
  if 0 then set &amp;amp;ds.;
  format _numeric_ missing. _character_ $missing.;
  length _NAME_ $ 32 _TYPE_ $ 1;
  declare hash _H_();
  _H_.defineKey("_NAME_");
  _H_.DefineDONE();

  do until(_E_);
    set &amp;amp;ds. end=_E_;

    do until(_NAME_='_NAME_');
      if _NAME_ NE '_NAME_' then 
        do;
          call vnext(_NAME_, _TYPE_, _N_);
          if NOT cmiss(vvaluex(_NAME_)) then rc=_H_.add();
        end;
    end;
  end;
  _H_.output(dataset:"work.onlyMissingData(where=((_NAME_ NE '_NAME_')))");
stop;
run;
%mend anyNonMissingData;

%anyNonMissingData(have)
proc print data = onlyMissingData;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Have is 8.47GB, log says:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: The data set WORK.ONLYMISSINGDATA has 201 observations and 1 variables.
NOTE: There were 5000000 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           1.45 seconds
      user cpu time       0.28 seconds
      system cpu time     1.17 seconds
      memory              1861.31k
      OS Memory           26652.00k
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'd say, not bad (both time and memory), but still 8GB is not a big data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But we can't do to much about that "all missing" search, its always O(n*k) time process(n=#of obs, k=#of vars).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 15:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931919#M366632</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-06-12T15:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931922#M366633</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;this is really nice.&amp;nbsp; Great to see application of CALL VNEXT and VVALUE&lt;FONT color="#FF0000"&gt;X&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Just for fun:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let size=100;
data have;
  array noMissC[&amp;amp;size.] $1 (&amp;amp;size.*"A");
  array noMissN[&amp;amp;size.]   (&amp;amp;size.*1)  ;
  array   MissC[&amp;amp;size.] $1            ;
  array   MissN[&amp;amp;size.]               ;
  do i = 1 to 5e6;
    output;
  end;
run;
/*
proc print;
run;
*/

options ls=max;

%macro anyNonMissingData(ds);
proc format;
  value missing
    ._-.z = " "
    other = "*"
  ;
  value $missing
    " " = " "
    other = "*"
  ;
run;
data _null_;
  if 0 then set &amp;amp;ds.;
  format _numeric_ missing. _character_ $missing.;
  length _NAME_ $ 32 _TYPE_ $ 1;
  declare hash _H_();
  _H_.defineKey("_NAME_");
  _H_.DefineDONE();

  do until(_E_);
    set &amp;amp;ds. end=_E_;

    do until(_NAME_='_NAME_');
      if _NAME_ NE '_NAME_' then 
        do;
          call vnext(_NAME_, _TYPE_, _N_);
          if NOT cmiss(vvaluex(_NAME_)) then rc=_H_.add();
        end;
    end;
  end;
  _H_.output(dataset:"work.onlyMissingData(where=((_NAME_ NE '_NAME_')))");
stop;
run;
%mend anyNonMissingData;

%anyNonMissingData(have)
proc print data = onlyMissingData;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Have is 8.47GB, log says:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: The data set WORK.ONLYMISSINGDATA has 201 observations and 1 variables.
NOTE: There were 5000000 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           1.45 seconds
      user cpu time       0.28 seconds
      system cpu time     1.17 seconds
      memory              1861.31k
      OS Memory           26652.00k
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'd say, not bad (both time and memory), but still 8GB is not a big data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But we can't do to much about that "all missing" search, its always O(n*k) time process(n=#of obs, k=#of vars).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 15:14:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931922#M366633</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-06-12T15:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931924#M366634</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/27897"&gt;@DrAbhijeetSafai&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know you've already received good responses for this. However, I decided to share my approach anyway which uses the max function in proc SQL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib=work kill nolist nowarn; quit;

data test;
	set sashelp.class;
	call missing(age);
	if _n_ = 1 then call missing(sex);
	sex2='';
run;


proc contents data=test out=contents;
run;


data _null_;
	set contents end=eof;
	length COLS $32767;
	retain COLS '';
	if _N_ = 1 then do;
		call execute ('PROC SQL;');
		call execute ('CREATE TABLE CHECK AS SELECT');	
	end;
	COLS = catx(", ", COLS, catx(" ", cats('max(',name,')'), "as", name));
	if EOF then do;
		call execute (COLS);
		call execute ('FROM TEST;');
		call execute ('QUIT;');
	end;
run;

/*Drop columns if they are missing on all rows*/
data _null_;
	set check end=eof;
	array n [*] _NUMERIC_;
	array c [*] _CHARACTER_;
	length COLS $200;
	call execute ('proc sql;');
	call execute ('ALTER TABLE TEST');
	call execute ('DROP COLUMN');
	do i=1 to dim(n);
		if missing(n[i]) then COLS = catx(", ", COLS, vname(n[i]));
	end;
	do i=1 to dim(c);
		if missing(c[i]) then COLS = catx(", ", COLS, vname(c[i]));
	end;
	call execute(COLS);
	call execute(';quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 15:49:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931924#M366634</guid>
      <dc:creator>Mazi</dc:creator>
      <dc:date>2024-06-12T15:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931928#M366635</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/27897"&gt;@DrAbhijeetSafai&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was also looking at &lt;A href="https://blogs.sas.com/content/iml/2011/09/19/count-the-number-of-missing-values-for-each-variable.html" target="_self"&gt;this&lt;/A&gt;. I found this one simpler. I am just trying to take all the variables out by using out= option in proc freq in the code below. Please look at the out= part which I have bolded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="sas"&gt;&lt;SPAN&gt;/* create a format to group missing and nonmissing */&lt;/SPAN&gt;
proc &lt;SPAN&gt;format&lt;/SPAN&gt;;
 value $missfmt &lt;SPAN&gt;' '&lt;/SPAN&gt;=&lt;SPAN&gt;'Missing'&lt;/SPAN&gt; other=&lt;SPAN&gt;'Not Missing'&lt;/SPAN&gt;;
 value  missfmt  . =&lt;SPAN&gt;'Missing'&lt;/SPAN&gt; other=&lt;SPAN&gt;'Not Missing'&lt;/SPAN&gt;;
&lt;SPAN&gt;run&lt;/SPAN&gt;;
&amp;nbsp;
&lt;SPAN&gt;proc freq&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=one; 
&lt;SPAN&gt;format&lt;/SPAN&gt; _CHAR_ $missfmt.; &lt;SPAN&gt;/* apply format for the duration of this PROC */&lt;/SPAN&gt;
tables _CHAR_ / &lt;STRONG&gt;out=test1&lt;/STRONG&gt; &lt;SPAN&gt;missing&lt;/SPAN&gt; missprint nocum nopercent;
&lt;SPAN&gt;format&lt;/SPAN&gt; &lt;SPAN&gt;_NUMERIC_&lt;/SPAN&gt; missfmt.;
tables &lt;SPAN&gt;_NUMERIC_&lt;/SPAN&gt; / &lt;SPAN&gt;missing&lt;/SPAN&gt; missprint nocum nopercent;
&lt;SPAN&gt;run&lt;/SPAN&gt;;&lt;/PRE&gt;
&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The OUT= option of the Tables data set only outputs the LAST result.&lt;/P&gt;
&lt;P&gt;You would have to make a call for each variable separately, with a separate output data set for each, for this to do what you want. Much better ways are shown.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 15:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931928#M366635</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-12T15:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931992#M366646</link>
      <description>&lt;P&gt;Many thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/464333"&gt;@Mazi&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124967"&gt;@tom_grant&lt;/a&gt;&amp;nbsp;, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;and all others for your response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was able to solve the issue but not easy way but by macro way. Somehow finally I found that the approach by macro will be better for me so I went ahead with that and the issue is solved. I would share the steps of what I did below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;First I used &lt;STRONG&gt;cmiss function&lt;/STRONG&gt; (works for numeric too) to find out if particular value is missing in a variable.&lt;/LI&gt;
&lt;LI&gt;Then by creating another variable I found &lt;STRONG&gt;accumulating total&lt;/STRONG&gt; of that variable (value of cmiss is 1 if the value is missing and 0 if it it not missing). In this way now I have count of number of values that are missing in a variable.&lt;/LI&gt;
&lt;LI&gt;I kept the &lt;STRONG&gt;last row&lt;/STRONG&gt; of this dataset (by end= option) and kept only those variable which will have counts of missing values.&lt;/LI&gt;
&lt;LI&gt;By &lt;STRONG&gt;proc contents&lt;/STRONG&gt; I found out how many rows are there in the given dataset.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;I &lt;STRONG&gt;joined&lt;/STRONG&gt; that dataset of proc contents with this dataset of one row.&lt;/LI&gt;
&lt;LI&gt;If the dataset contains say 168 observations and if there 168 missing values for a variable, that means all the values are missing for that variable. (And that is what I was searching for: &lt;STRONG&gt;variables having all missing values&lt;/STRONG&gt;).&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;Once found, I &lt;STRONG&gt;created a flag&lt;/STRONG&gt; for those variables for which number of missing values are number of records in the dataset.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;All this I put in the &lt;STRONG&gt;macro&lt;/STRONG&gt; which will do it for all the variables one by one by using &lt;STRONG&gt;do while loop.&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And in this way the issue was solved. I would have liked to share the code for this but I will not be able to do it because I will need to type out the code again and that is very time consuming.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks to all those who responded. It was a fun exercise for me. I thought I will be able to avoid macro but later I found that macro is a better way to solve it. As I found this answer working for me, I will mark this as accepted answer.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 18:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931992#M366646</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-06-12T18:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931995#M366648</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;, Thanks a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro and do while loop is the approach I used. Many thanks once again!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 18:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931995#M366648</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-06-12T18:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931996#M366649</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your saying that "&lt;SPAN&gt;The OUT= option of the Tables data set only outputs the LAST result." is so much correct! Thanks for pointing it out.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- Dr. Abhijeet Safai&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 18:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931996#M366649</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-06-12T18:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out if all the values of a variable (numeric or character) are missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931998#M366651</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124967"&gt;@tom_grant&lt;/a&gt;&amp;nbsp;That is interesting! Thanks for information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 19:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931998#M366651</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-06-12T19:00:41Z</dc:date>
    </item>
  </channel>
</rss>

