<?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 How to loop through columns of dataset and test for missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519289#M140640</link>
    <description>&lt;P&gt;Hello All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I would like the community's help on looping around the columns of a data set, check if a column has at least one row with a missing value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data values;
   input @1 var1 3. @5 var2 3.;
   if missing(var1) then
      do;
         put 'Variable 1 is Missing.';
      end;
   else if missing(var2) then
      do;
         put 'Variable 2 is Missing.';
      end;
   datalines;
127
988 195
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; This is the manual way I can see from Missing() documentation and it would work for small datasets. But I would like the ability to do this over large data sets easily.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Dec 2018 21:37:31 GMT</pubDate>
    <dc:creator>UdayGuntupalli</dc:creator>
    <dc:date>2018-12-06T21:37:31Z</dc:date>
    <item>
      <title>How to loop through columns of dataset and test for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519289#M140640</link>
      <description>&lt;P&gt;Hello All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I would like the community's help on looping around the columns of a data set, check if a column has at least one row with a missing value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data values;
   input @1 var1 3. @5 var2 3.;
   if missing(var1) then
      do;
         put 'Variable 1 is Missing.';
      end;
   else if missing(var2) then
      do;
         put 'Variable 2 is Missing.';
      end;
   datalines;
127
988 195
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; This is the manual way I can see from Missing() documentation and it would work for small datasets. But I would like the ability to do this over large data sets easily.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 21:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519289#M140640</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-12-06T21:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through columns of dataset and test for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519291#M140641</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can loop through columns by specifying an ARRAY structure (typically a one-dimensional array), where there is one array element for each variables of interest:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data values;
   input @1 var1 3. @5 var2 3.;
  array v {2} var1 var2;
  do i=1 to 2;
     if missing(v{I}) then put 'Variable ' I 'is Missing.'  v{I}=;
  end;
datalines;
127
988 195
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 21:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519291#M140641</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-06T21:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through columns of dataset and test for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519296#M140643</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; This looks great. However, I would like to request some extra details around the array declaration for my learning:&amp;nbsp;&lt;BR /&gt;1. Why are you manually declaring column names after the declaration of&amp;nbsp; the array ?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data values;
   input @1 var1 3. @5 var2 3.; 
  array v {2} var1 var2; * Manually declaring columns here ?; 
  do i=1 to 2;
     if missing(v{I}) then put 'Variable ' I 'is Missing.'  v{I}=;
  end;
datalines;
127
988 195
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Is there a way to automatically get all the column names and use it in the loop ?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 22:05:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519296#M140643</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-12-06T22:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through columns of dataset and test for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519297#M140644</link>
      <description>&lt;P&gt;Slightly modified version&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data values;
	input @1 var1 3. @5 var2 3.;
	array var[*] var:;
	do i=1 to dim(var);
		if missing(var[i]) then do;
			put "Variable "  i "is missing";
		end;
	end;
drop i ;
datalines;
127
988 195
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 22:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519297#M140644</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-12-06T22:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through columns of dataset and test for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519300#M140645</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/27543"&gt;@UdayGuntupalli&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This looks great. However, I would like to request some extra details around the array declaration for my learning:&amp;nbsp;&lt;BR /&gt;1. Why are you manually declaring column names after the declaration of&amp;nbsp; the array ?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Because&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The array statement needs a way to have correspondence between the array element and the reference variable.&amp;nbsp; A specific listg of variable names in one way to do this, and you only showed 2 variables.&lt;/LI&gt;
&lt;LI&gt;You didn't specify whether there are other variables not to include in the array.&lt;/LI&gt;
&lt;/OL&gt;
&lt;HR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/27543"&gt;@UdayGuntupalli&lt;/a&gt;@&amp;nbsp;also wrote:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;2. Is there a way to automatically get all the column names and use it in the loop ?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By "all the columns names" do you mean all the numeric variables?&amp;nbsp; If yes, then use&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array v {*} _numeric_ ;&lt;BR /&gt;and&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(v);&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 22:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519300#M140645</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-06T22:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through columns of dataset and test for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519395#M140672</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods select none;
ods output nlevels=want;
proc freq data=have nlevels;
table _all_;
run;
ods select all;
proc sql noprint;
select TableVar into : missing_variables separated by ' '
from want
where NNonMissLevels=0;
quit;
%put Missing variables are: &amp;amp;missing_variables ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Dec 2018 12:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-through-columns-of-dataset-and-test-for-missing/m-p/519395#M140672</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-07T12:46:53Z</dc:date>
    </item>
  </channel>
</rss>

