<?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: Deleting Variables When all Values=0 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33298#M6483</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your question is very interesting.&lt;/P&gt;&lt;P&gt;How about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data zero;
input name $ score1-score4;
cards;
peter 10 23 0 65
patrick 23 45 0 65
art 34 56 0 56
sharp 34 65 0 86
;
run;
proc stdize data=zero out=_zero missing=999999 reponly;
run;
proc means data=_zero noprint ;
 var _numeric_;
 output out=drop(drop=_type_ _freq_) sum=;
run; 
data _null_;
 set drop;
 array drop{*} _numeric_;
 array drop_list{200} $ 32 _temporary_; 
 do j=1 to dim(drop) ;
&amp;nbsp; if drop{j} eq 0 then drop_list{j}=vname(drop{j}); 
 end;
 call symput('drop_var',catx(' ',of drop_list{*}));
 stop;
run;
data want;
 set zero(drop=&amp;amp;drop_var);
run;
data want;
 set want;
 array num{*} _numeric_;
 do j=1 to dim(num) ;
&amp;nbsp; if num{j} eq 999999 then num{j}=.; 
 end;
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;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Jul 2011 10:12:37 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-07-19T10:12:37Z</dc:date>
    <item>
      <title>Deleting Variables When all Values=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33293#M6478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times; font-size: 12pt;"&gt;Hi all,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times; font-size: 12pt;"&gt;I find a plethora of info on deleting missing values, but I can't seem to figure out how to remove 0's :smileyplain: I want to delete a variable if values from all observations =0. It seems like there would be a simple way to do this, but can't turn anything up. Ideas?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times; font-size: 12pt;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 21:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33293#M6478</guid>
      <dc:creator>jmgorzo</dc:creator>
      <dc:date>2011-07-18T21:00:17Z</dc:date>
    </item>
    <item>
      <title>Deleting Variables When all Values=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33294#M6479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not modify and use the code at: &lt;A href="http://support.sas.com/kb/24/622.html"&gt;http://support.sas.com/kb/24/622.html&lt;/A&gt; ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding-top: 10px; padding-bottom: 8px; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;&lt;CODE style="padding-top: 10px; padding-bottom: 8px; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;Just change the two lines:&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE style="padding-top: 10px; padding-bottom: 8px; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;&lt;CODE style="padding-top: 10px; padding-bottom: 8px; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;if num_vars(i) ne . then num_miss(i)='non-miss';&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE style="padding-top: 10px; padding-bottom: 8px; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;&lt;CODE style="padding-top: 10px; padding-bottom: 8px; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;and if char_vars(i) ne '' then char_miss(i)='non-miss';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE style="padding-top: 10px; padding-bottom: 8px; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;to&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="display: block; margin-left: 0pt; padding-top: 10px; padding-bottom: 8px; white-space: pre; width: auto; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;&lt;CODE style="padding-top: 10px; padding-bottom: 8px; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;if num_vars(i) ne 0 then num_miss(i)='non-miss';&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE style="display: block; margin-left: 0pt; padding-top: 10px; padding-bottom: 8px; white-space: pre; width: auto; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;&lt;CODE style="padding-top: 10px; padding-bottom: 8px; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;and if char_vars(i) ne '0' then char_miss(i)='non-miss';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE style="padding-top: 10px; padding-bottom: 8px; font-weight: normal; font-style: normal; font-size: 11px; line-height: 1.25em; font-family: monospace; text-align: left;"&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 21:33:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33294#M6479</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-18T21:33:04Z</dc:date>
    </item>
    <item>
      <title>Deleting Variables When all Values=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33295#M6480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There was a post here just before I went for dinner and now it has disappeared.&amp;nbsp; I looked at the code you sent and there was only one line that had to be corrected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It currently reads: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* LIST will contain the list of variables to be dropped.&amp;nbsp; Ensure&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* it's length is sufficient.&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;&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; */&lt;/P&gt;&lt;P&gt;&amp;nbsp; length list $ 50; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but, for your data, should read:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* LIST will contain the list of variables to be dropped.&amp;nbsp; Ensure&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* it's length is sufficient.&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;&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; */&lt;/P&gt;&lt;P&gt;&amp;nbsp; length list $ 200; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 23:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33295#M6480</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-18T23:53:28Z</dc:date>
    </item>
    <item>
      <title>Deleting Variables When all Values=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33296#M6481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haha yes, sorry, I took that down once I found the same thing and realized it was a stupid question. Thank you so much for your help!! As you saw I modified the code from the site to only look for numeric variables. Worked like a charm. Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 23:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33296#M6481</guid>
      <dc:creator>jmgorzo</dc:creator>
      <dc:date>2011-07-18T23:58:08Z</dc:date>
    </item>
    <item>
      <title>Deleting Variables When all Values=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33297#M6482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only stupid question I've ever seen is the one portrayed in the logo at:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.facebook.com/pages/Society-For-Asking-Stupid-Questions/169774899701771"&gt;http://www.facebook.com/pages/Society-For-Asking-Stupid-Questions/169774899701771&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, it would help if you marked this question as answered so that others don't spend unnecessary time on it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jul 2011 00:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33297#M6482</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-19T00:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Variables When all Values=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33298#M6483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your question is very interesting.&lt;/P&gt;&lt;P&gt;How about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data zero;
input name $ score1-score4;
cards;
peter 10 23 0 65
patrick 23 45 0 65
art 34 56 0 56
sharp 34 65 0 86
;
run;
proc stdize data=zero out=_zero missing=999999 reponly;
run;
proc means data=_zero noprint ;
 var _numeric_;
 output out=drop(drop=_type_ _freq_) sum=;
run; 
data _null_;
 set drop;
 array drop{*} _numeric_;
 array drop_list{200} $ 32 _temporary_; 
 do j=1 to dim(drop) ;
&amp;nbsp; if drop{j} eq 0 then drop_list{j}=vname(drop{j}); 
 end;
 call symput('drop_var',catx(' ',of drop_list{*}));
 stop;
run;
data want;
 set zero(drop=&amp;amp;drop_var);
run;
data want;
 set want;
 array num{*} _numeric_;
 do j=1 to dim(num) ;
&amp;nbsp; if num{j} eq 999999 then num{j}=.; 
 end;
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;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jul 2011 10:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Variables-When-all-Values-0/m-p/33298#M6483</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-07-19T10:12:37Z</dc:date>
    </item>
  </channel>
</rss>

