<?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: Detect and delete null columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Detect-and-delete-null-columns/m-p/324626#M72081</link>
    <description>&lt;P&gt;This question is asked often. See the SAS Sample &lt;A href="http://support.sas.com/kb/24/622.html" target="_self"&gt;"Drop variables from a SAS data set whose values are all missing"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also search this forum or the internet by using queries such as&lt;/P&gt;
&lt;P&gt;SAS delete variables all missing&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jan 2017 16:41:13 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-01-13T16:41:13Z</dc:date>
    <item>
      <title>Detect and delete null columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detect-and-delete-null-columns/m-p/324619#M72080</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Everything is in the title.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whatever the size of my SAS table is, whatever the number of columns is, is there a way to travel along every column to detect null colums, and to delete them?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I mean by null column is only a column where all values are null, without exception.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was looking for with PROC SQL but it seems very difficult...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 16:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detect-and-delete-null-columns/m-p/324619#M72080</guid>
      <dc:creator>Planck</dc:creator>
      <dc:date>2017-01-13T16:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Detect and delete null columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detect-and-delete-null-columns/m-p/324626#M72081</link>
      <description>&lt;P&gt;This question is asked often. See the SAS Sample &lt;A href="http://support.sas.com/kb/24/622.html" target="_self"&gt;"Drop variables from a SAS data set whose values are all missing"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also search this forum or the internet by using queries such as&lt;/P&gt;
&lt;P&gt;SAS delete variables all missing&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 16:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detect-and-delete-null-columns/m-p/324626#M72081</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-01-13T16:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Detect and delete null columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detect-and-delete-null-columns/m-p/324635#M72082</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;

%macro drop_missing_vars(DSET);

* check missings vars;
ods select none;
ods output nlevels=_MISSINGVARS (where=(nmisslevels&amp;gt;0 and nnonmisslevels=0));
proc freq data=&amp;amp;DSET nlevels;
run;

* get missing vars names;
%let _MISSINGVARS=;
proc sql noprint;
select TABLEVAR into :_MISSINGVARS separated by ' ' from _MISSINGVARS;
quit;

* if there is any, drop;
%if %str(&amp;amp;_MISSINGVARS) ne %then %do;
data want;
set have (drop=&amp;amp;_MISSINGVARS);
run;
%end;

%mend drop_missing_vars;

%drop_missing_vars(have); * run macro providing the dataset name;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here more on FREQ and nlevels option:&amp;nbsp;&lt;A href="http://support.sas.com/kb/30/867.html" target="_blank"&gt;http://support.sas.com/kb/30/867.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The rest is just building a list into a macro var and afterthat drop the vars.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope it helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detect-and-delete-null-columns/m-p/324635#M72082</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2017-01-13T17:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Detect and delete null columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detect-and-delete-null-columns/m-p/324671#M72091</link>
      <description>&lt;P&gt;And just a note that SAS doesn't really have a NULL value, it has missing which can often be considered the same, but in certain cases and DBs they are not.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 19:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detect-and-delete-null-columns/m-p/324671#M72091</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-13T19:03:31Z</dc:date>
    </item>
  </channel>
</rss>

