<?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: Delete columns if the value is empty for each field in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21408#M3893</link>
    <description>&amp;gt; Is it possible to delete - drop columns if there&lt;BR /&gt;
&amp;gt; isn't any value in for each row of the dataset?&lt;BR /&gt;
&lt;BR /&gt;
Yes but you have to figure out what columns contain all missing values.&lt;BR /&gt;
&lt;BR /&gt;
Here is one method.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
  missing a b;&lt;BR /&gt;
  input name$ a   b   c   d   e;&lt;BR /&gt;
  *keep name a;&lt;BR /&gt;
  cards;&lt;BR /&gt;
 x 2 . . . .&lt;BR /&gt;
 y . . 3 . .&lt;BR /&gt;
 z . a . . .&lt;BR /&gt;
 p . . . b .&lt;BR /&gt;
 q . . . . .&lt;BR /&gt;
;;;;&lt;BR /&gt;
  run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
  run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc format; *To speedup PROC FREQ;&lt;BR /&gt;
   value allmiss ._-.z=. other=1;&lt;BR /&gt;
   value $allmiss ' '=' ' other='1';&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
ods select nlevels;&lt;BR /&gt;
ods output nlevels=nlevels;&lt;BR /&gt;
proc freq levels;&lt;BR /&gt;
   format _character_ $allmiss. _numeric_ allmiss.;&lt;BR /&gt;
   run;&lt;BR /&gt;
ods output close;&lt;BR /&gt;
&lt;BR /&gt;
data nlevels; &lt;BR /&gt;
   /*NNonMissLevels will not exist when there are no*/&lt;BR /&gt;
   /*variables with missing values*/&lt;BR /&gt;
   retain NNonMissLevels -1;&lt;BR /&gt;
   set nlevels;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
%let allMiss=;&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
   select tableVar into :allmiss separated by ' '&lt;BR /&gt;
   from Nlevels where NNonMissLevels = 0;&lt;BR /&gt;
   quit;&lt;BR /&gt;
   run;&lt;BR /&gt;
%let allmiss = %sysfunc(IFC(&amp;amp;allmiss eq,%str( ),drop=&amp;amp;allmiss));&lt;BR /&gt;
%put NOTE: ALLMISS=&amp;amp;allMiss;&lt;BR /&gt;
&lt;BR /&gt;
proc report data=have(&amp;amp;allmiss) nowd;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Thu, 03 Mar 2011 13:42:29 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2011-03-03T13:42:29Z</dc:date>
    <item>
      <title>Delete columns if the value is empty for each field</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21407#M3892</link>
      <description>Is it possible to delete - drop columns if there isn't any value in for each row of the dataset?</description>
      <pubDate>Thu, 03 Mar 2011 11:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21407#M3892</guid>
      <dc:creator>Filipvdr</dc:creator>
      <dc:date>2011-03-03T11:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Delete columns if the value is empty for each field</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21408#M3893</link>
      <description>&amp;gt; Is it possible to delete - drop columns if there&lt;BR /&gt;
&amp;gt; isn't any value in for each row of the dataset?&lt;BR /&gt;
&lt;BR /&gt;
Yes but you have to figure out what columns contain all missing values.&lt;BR /&gt;
&lt;BR /&gt;
Here is one method.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
  missing a b;&lt;BR /&gt;
  input name$ a   b   c   d   e;&lt;BR /&gt;
  *keep name a;&lt;BR /&gt;
  cards;&lt;BR /&gt;
 x 2 . . . .&lt;BR /&gt;
 y . . 3 . .&lt;BR /&gt;
 z . a . . .&lt;BR /&gt;
 p . . . b .&lt;BR /&gt;
 q . . . . .&lt;BR /&gt;
;;;;&lt;BR /&gt;
  run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
  run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc format; *To speedup PROC FREQ;&lt;BR /&gt;
   value allmiss ._-.z=. other=1;&lt;BR /&gt;
   value $allmiss ' '=' ' other='1';&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
ods select nlevels;&lt;BR /&gt;
ods output nlevels=nlevels;&lt;BR /&gt;
proc freq levels;&lt;BR /&gt;
   format _character_ $allmiss. _numeric_ allmiss.;&lt;BR /&gt;
   run;&lt;BR /&gt;
ods output close;&lt;BR /&gt;
&lt;BR /&gt;
data nlevels; &lt;BR /&gt;
   /*NNonMissLevels will not exist when there are no*/&lt;BR /&gt;
   /*variables with missing values*/&lt;BR /&gt;
   retain NNonMissLevels -1;&lt;BR /&gt;
   set nlevels;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
%let allMiss=;&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
   select tableVar into :allmiss separated by ' '&lt;BR /&gt;
   from Nlevels where NNonMissLevels = 0;&lt;BR /&gt;
   quit;&lt;BR /&gt;
   run;&lt;BR /&gt;
%let allmiss = %sysfunc(IFC(&amp;amp;allmiss eq,%str( ),drop=&amp;amp;allmiss));&lt;BR /&gt;
%put NOTE: ALLMISS=&amp;amp;allMiss;&lt;BR /&gt;
&lt;BR /&gt;
proc report data=have(&amp;amp;allmiss) nowd;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 03 Mar 2011 13:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21408#M3893</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-03-03T13:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Delete columns if the value is empty for each field</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21409#M3894</link>
      <description>ok that works quite nice! thanks a lot.&lt;BR /&gt;
&lt;BR /&gt;
Is there something similar like: if this variable has always the same value ( you don't know the value up front)</description>
      <pubDate>Fri, 04 Mar 2011 11:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21409#M3894</guid>
      <dc:creator>Filipvdr</dc:creator>
      <dc:date>2011-03-04T11:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Delete columns if the value is empty for each field</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21410#M3895</link>
      <description>[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
  missing a b;&lt;BR /&gt;
  input name$ a   b   c   d   e;&lt;BR /&gt;
  *keep name a;&lt;BR /&gt;
  cards;&lt;BR /&gt;
 x 2 3 . . 7&lt;BR /&gt;
 y . 3 3 . 7&lt;BR /&gt;
 z . 3 . . 7&lt;BR /&gt;
 p . 3 . b 7&lt;BR /&gt;
 q . 3 . . 7&lt;BR /&gt;
;;;;&lt;BR /&gt;
  run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
  run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
ods select nlevels;&lt;BR /&gt;
ods output nlevels=nlevels;&lt;BR /&gt;
proc freq levels;&lt;BR /&gt;
   run;&lt;BR /&gt;
ods output close;&lt;BR /&gt;
&lt;BR /&gt;
data nlevels; &lt;BR /&gt;
   /*NNonMissLevels will not exist when there are no*/&lt;BR /&gt;
   /*variables with missing values*/&lt;BR /&gt;
   retain NNonMissLevels 1;&lt;BR /&gt;
   set nlevels;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
%let oneLevel=;&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
   select tableVar into :oneLevel separated by ' '&lt;BR /&gt;
   from Nlevels where NLevels eq 1 and NNonMissLevels eq 1;&lt;BR /&gt;
   quit;&lt;BR /&gt;
   run;&lt;BR /&gt;
%let oneLevel = %sysfunc(IFC(&amp;amp;oneLevel eq,%str( ),drop=&amp;amp;oneLevel));&lt;BR /&gt;
%put NOTE: oneLevel=&amp;amp;oneLevel;&lt;BR /&gt;
&lt;BR /&gt;
proc report data=have(&amp;amp;oneLevel) nowd;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 04 Mar 2011 13:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21410#M3895</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-03-04T13:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Delete columns if the value is empty for each field</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21411#M3896</link>
      <description>ok thanks but i'm bumping into a problem now&lt;BR /&gt;
&lt;BR /&gt;
this is what i want to have: clicking on id gives me outputdata but this data can differ according to the id&lt;BR /&gt;
&lt;BR /&gt;
Stored Process 2 handles the id and gives the output&lt;BR /&gt;
1 - want to get rid of columns where all missings (your first piece of code)&lt;BR /&gt;
2 - want go place a header text where all rows have the same value (your 2nd piece of code)&lt;BR /&gt;
&lt;BR /&gt;
when i run these codes after each other in my STP it gives the following error:&lt;BR /&gt;
&lt;BR /&gt;
NOTE: ALLMISS=drop=PmProcedure WaferId MeasKey sWaferId sNumberOfSites aDieNumber Thick_2 Thick_3 Sum_1 Refract_1 Refract_2&lt;BR /&gt;
201       +&lt;BR /&gt;
&lt;BR /&gt;
202       +&lt;BR /&gt;
&lt;BR /&gt;
203       +/* added */&lt;BR /&gt;
&lt;BR /&gt;
204       +proc print;  run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 37 observations read from the data set WORK.NLEVELS.&lt;BR /&gt;
NOTE: The PROCEDURE PRINT printed pages 6-7.&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
      &lt;BR /&gt;
&lt;BR /&gt;
204      !+                 &lt;BR /&gt;
&lt;BR /&gt;
205       +ods select nlevels;&lt;BR /&gt;
&lt;BR /&gt;
206       +ods output nlevels=nlevels;&lt;BR /&gt;
&lt;BR /&gt;
207       +proc freq levels;   run;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: You cannot open WORK.NLEVELS.DATA for output access with member-level control because WORK.NLEVELS.DATA is in use by you in resource environment FREQ (223).&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
NOTE: SAS set option OBS=0 and will continue to check statements. This may cause NOTE: No observations in data set.&lt;BR /&gt;
NOTE: There were 37 observations read from the data set WORK.NLEVELS.&lt;BR /&gt;
NOTE: The PROCEDURE FREQ printed page 8.&lt;BR /&gt;
NOTE: PROCEDURE FREQ used (Total process time):</description>
      <pubDate>Fri, 04 Mar 2011 13:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21411#M3896</guid>
      <dc:creator>Filipvdr</dc:creator>
      <dc:date>2011-03-04T13:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Delete columns if the value is empty for each field</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21412#M3897</link>
      <description>I don't know about stored processes.  You might try ODS OUTPUT CLOSE or a different data set name NLEVELS1 and NLEVELS2.</description>
      <pubDate>Fri, 04 Mar 2011 14:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Delete-columns-if-the-value-is-empty-for-each-field/m-p/21412#M3897</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-03-04T14:21:01Z</dc:date>
    </item>
  </channel>
</rss>

