<?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: Dropping variables with null values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/344860#M63502</link>
    <description>&lt;PRE&gt;
Check @MikeZeb 's solution.

&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Mar 2017 03:24:05 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-03-28T03:24:05Z</dc:date>
    <item>
      <title>Dropping variables with null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185892#M47203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have dataset with around 80-90 variables. I want to create dataset&amp;nbsp; in such way that I have to drop those variables which are null for all records. It should be dynamic in such way if new variable is added with null value it should be dropped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2014 12:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185892#M47203</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2014-09-04T12:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping variables with null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185893#M47204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Q1 = Why 80-90 variables - consider normalizing your data!&lt;/P&gt;&lt;P&gt;Try the below example and modify for your particular data:&lt;/P&gt;&lt;P&gt;data work.have;&lt;BR /&gt;&amp;nbsp; length a b c d $20;&lt;BR /&gt;&amp;nbsp; a="GHGYT";b="£$"; output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; create table TO_PROCESS &lt;BR /&gt;&amp;nbsp; (&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NAME char(50),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CNT num&lt;BR /&gt;&amp;nbsp; );&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;data tmp;&lt;BR /&gt;&amp;nbsp; set sashelp.vcolumn (where=(libname="WORK" and MEMNAME="HAVE"));&lt;BR /&gt;&amp;nbsp; call execute('proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert into WORK.TO_PROCESS&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set NAME="'||strip(NAME)||'",&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CNT=(select count('||strip(NAME)||') from WORK.HAVE where '||strip(NAME)||' is not null);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;');&lt;BR /&gt;run;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;&amp;nbsp; select&amp;nbsp; NAME&lt;BR /&gt;&amp;nbsp; into&amp;nbsp;&amp;nbsp;&amp;nbsp; :DROP_LIST separated by ' '&lt;BR /&gt;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; WORK.TO_PROCESS&lt;BR /&gt;&amp;nbsp; where&amp;nbsp;&amp;nbsp; CNT=0;&lt;BR /&gt;quit;&lt;BR /&gt;data want (drop=&amp;amp;drop_list.);&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2014 12:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185893#M47204</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-09-04T12:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping variables with null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185894#M47205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/24/612.html" title="http://support.sas.com/kb/24/612.html"&gt;24612 - Delete variables that have only missing values&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2014 12:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185894#M47205</guid>
      <dc:creator>Hima</dc:creator>
      <dc:date>2014-09-04T12:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping variables with null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185895#M47206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My code is better ,shorter and faster than support . sas . com .&amp;nbsp; &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data class;
set sashelp.class;
call missing(age,name);
run;

proc sql noprint ;
 select cat('n(',strip(name),') as ',name)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;into : list separated by ','
&amp;nbsp; from dictionary.columns
&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='CLASS';
create table temp as 
 select &amp;amp;list from class;
quit;
data _null_;
 set temp;
 length drop $ 4000; 
 array x{*} _numeric_;
 do i=1 to dim(x);
&amp;nbsp; if x{i}=0 then drop=catx(' ',drop,vname(x{i}));
 end;
 call symputx('drop',drop);
run;
data want;
 set class(drop= &amp;amp;drop );
run;



&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2014 14:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185895#M47206</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-09-04T14:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping variables with null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185896#M47207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... you got a very nice answer from Ksharp, but here's another idea that use PROC FREQ rather than PROC SQL to find the variables with all missing values ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data class;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;set sashelp.class;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;call missing(age,name);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;ods output nlevels=nlvs (where=(nnonmisslevels eq 0));&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc freq data=class nlevels;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;ods select nlevels;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc sql noprint ;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;select tablevar into :drop separated by ' '&amp;nbsp; from nlvs;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;set class(drop=&amp;amp;drop);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ps&amp;nbsp; more on NLEVELS at &lt;A href="http://support.sas.com/kb/30/867.html" title="http://support.sas.com/kb/30/867.html"&gt;30867 - Modernizing Your SAS Code: PROC FREQ Applications&lt;/A&gt; and in Appendix C of&amp;nbsp; &lt;A href="http://www.lexjansen.com/nesug/nesug11/ds/ds12.pdf" title="http://www.lexjansen.com/nesug/nesug11/ds/ds12.pdf"&gt;http://www.lexjansen.com/nesug/nesug11/ds/ds12.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2014 21:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185896#M47207</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2014-09-05T21:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping variables with null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185897#M47208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; and whoever has the answer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this another "undocumented" feature? I could NOT find the Docs addressing the use of function N() in your code.&lt;/P&gt;&lt;P&gt;1)In the Docs I can find, N( ) is for numeric.&lt;/P&gt;&lt;P&gt;2) N( ) is NOT a summary function for Proc SQL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So ???&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 14:48:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185897#M47208</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-09-16T14:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping variables with null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185898#M47209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Never mind. Found it. I wasn't thorough enough.&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#n123fsko39j44pn16zlt087e1m2h.htm" title="http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#n123fsko39j44pn16zlt087e1m2h.htm"&gt;SAS(R) 9.3 SQL Procedure User's Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 15:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/185898#M47209</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-09-16T15:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping variables with null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/344760#M63496</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;, Is it possible to drop null variables without specifying by variable names because I have hundreds of them?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 19:59:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/344760#M63496</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-27T19:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping variables with null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/344860#M63502</link>
      <description>&lt;PRE&gt;
Check @MikeZeb 's solution.

&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Mar 2017 03:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dropping-variables-with-null-values/m-p/344860#M63502</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-28T03:24:05Z</dc:date>
    </item>
  </channel>
</rss>

