<?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: Detecting  blank variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20236#M3137</link>
    <description>Can't, you'll have to filter those out after the fact.&lt;BR /&gt;
That is, you will have to filter the empty rows while reading in the data, and then filter out empty columns later.&lt;BR /&gt;
&lt;BR /&gt;
We use Excel spreadsheets as a simple mechanism to hold configuration information.  It is easy to edit and print the information.  The first row contains the field names, and all non-used rows and columns are "deleted" or "empty" so that SAS considers them "missing" and doesn't read them.  Since the first row contains the field names, SAS automatically assigns variables (variable names and labels) to those columns, and all subsequent rows are read in as data.  Our code then assumes specific column names.  If you are being handed amorphous Excel spreadsheets, then your job is going to be a lot harder, but I would also question as to "why?" what is the purpose?  The point of SAS is to do data analysis against either massive amounts of data, or in very sophisticated manners, perhaps applying highly sophisticated (and preprogrammed in "proc"s) analyses to the data.  If the input are unknown Excel spreadsheets, then how is the system going to know what to do with the data?

Message was edited by: Chuck</description>
    <pubDate>Mon, 26 May 2008 15:36:59 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-05-26T15:36:59Z</dc:date>
    <item>
      <title>Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20223#M3124</link>
      <description>Is there any easy way to detect any variables in a datset that has all blank or missing values ? &lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Wed, 21 May 2008 18:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20223#M3124</guid>
      <dc:creator>Kwok</dc:creator>
      <dc:date>2008-05-21T18:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20224#M3125</link>
      <description>You could use proc freq on all variables and visually inspect.  Alternatively, you could output the results of proc freq and inspect the resulting datset.</description>
      <pubDate>Wed, 21 May 2008 19:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20224#M3125</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-21T19:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20225#M3126</link>
      <description>[pre]&lt;BR /&gt;
if n_value = . then missing="true";&lt;BR /&gt;
if s_value = " " then blank = "true";&lt;BR /&gt;
 &lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select * from indata where field is missing;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 21 May 2008 21:01:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20225#M3126</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-21T21:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20226#M3127</link>
      <description>Hi Chuck,&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your interesting code. But maybe I did not present my issue clear enough. What I am looking for is to elminating all the varaibles(not variable value) from a dataset when ALL their values are blank or missing. For example, If I am reading from an excel spreadsheet with&lt;BR /&gt;
&lt;BR /&gt;
data file3;&lt;BR /&gt;
  set inf.'Sheet1$b4:iv64000'n;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I want to elminate all the excel blank columns in my dataset file3. &lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 22 May 2008 11:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20226#M3127</guid>
      <dc:creator>Kwok</dc:creator>
      <dc:date>2008-05-22T11:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20227#M3128</link>
      <description>By the way, I need a way to eliminate the blank rows too. Thanks</description>
      <pubDate>Thu, 22 May 2008 11:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20227#M3128</guid>
      <dc:creator>Kwok</dc:creator>
      <dc:date>2008-05-22T11:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20228#M3129</link>
      <description>The solution would require multiple steps.&lt;BR /&gt;
&lt;BR /&gt;
Eliminating blank rows is easiest and can be done in the initial read.&lt;BR /&gt;
Test if each column is missing/blank, if any column is not missing/blank, then output that row.&lt;BR /&gt;
&lt;BR /&gt;
You should know in advance which columns are of interest so that you don't have to test all 255 Excel columns.&lt;BR /&gt;
&lt;BR /&gt;
SAS can easily control which columns are in a table through the use of keep and drop (both statements and dataset options).  But, programmatically determining which to keep or drop is non-trivial.  I expect this will require some MACRO programming to create a KEEP or DROP statement to use in a DATA step or a SELECT statement to use with PROC SQL; CREATE TABLE _________ as ...;</description>
      <pubDate>Thu, 22 May 2008 12:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20228#M3129</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-22T12:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20229#M3130</link>
      <description>Hi Chuck,&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your reply. I just hoping for some easier way to get this done but I guess I have to settle to converting the dataset variables into an macor array and then examine them one by one.in a macro do loop.&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 22 May 2008 12:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20229#M3130</guid>
      <dc:creator>Kwok</dc:creator>
      <dc:date>2008-05-22T12:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20230#M3131</link>
      <description>Hi Chuck,&lt;BR /&gt;
&lt;BR /&gt;
One more thing, even I define to read in 255 column and 64000 rows, SAS do eliminated a lot of blank columns and rows. In this case I was ended up with 11 columns and 300 rows in the dataset file3. However, out of the 11 columns there are about 5 blank colums (those columns SAS assign variables name such F2,F3..) and about 75 blank rows. The excel spread sheet actual has 6 column and 225 rows of data. I do not know how SAS can eliminae most rows and columns and not the others. It must have something to do with the way excel was set up that SAS think it is not an empty columns/row. Do you have any experience in readin excel in ?&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 22 May 2008 12:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20230#M3131</guid>
      <dc:creator>Kwok</dc:creator>
      <dc:date>2008-05-22T12:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20231#M3132</link>
      <description>No, you don't have to convert all the variables into a macro variables ...&lt;BR /&gt;
&lt;BR /&gt;
You can determine if a column is blank by using a single select distinct max(...) statement for each column, then inspect the result within a macro using an open, fetchobs, varn and varc, etc.</description>
      <pubDate>Fri, 23 May 2008 12:04:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20231#M3132</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-23T12:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20232#M3133</link>
      <description>Yes, we do read in Excel spreadsheets.&lt;BR /&gt;
If your code is correct, it will drop all the columns and all the rows properly.</description>
      <pubDate>Fri, 23 May 2008 12:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20232#M3133</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-23T12:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20233#M3134</link>
      <description>after SAS loads your work sheet data try steps like[pre]&lt;BR /&gt;
data reduced_rows( drop= empty) ;&lt;BR /&gt;
   set that_data end= eof;&lt;BR /&gt;
   array nums(*) _numeric_ _n_ ; * have at least one numeric ;&lt;BR /&gt;
   retain empty ' ' ;&lt;BR /&gt;
   array chrs(*) _character_ empty ;&lt;BR /&gt;
&lt;BR /&gt;
**** mark non-empty columns ;&lt;BR /&gt;
   array numsc(1000) _temporary_; * assume have no more than 1000 num var ;&lt;BR /&gt;
   array chrsc(1000) _temporary_; * assume have no more than 1000 chr var ;&lt;BR /&gt;
   do _n_ = 1 to dim(nums) ;&lt;BR /&gt;
          numsc(_n_) + ^missing( nums(_n_)) ;&lt;BR /&gt;
   end;&lt;BR /&gt;
   do _n_ = 1 to dim(chrs) ;&lt;BR /&gt;
          chrsc(_n_) + ^missing( chrs(_n_)) ;&lt;BR /&gt;
   end;&lt;BR /&gt;
     &lt;BR /&gt;
**** after looking through all data, prepare a drop list for empty columns ;&lt;BR /&gt;
  if eof then do;&lt;BR /&gt;
                           %let drop_list= ; *ensure prepared and empty by default;&lt;BR /&gt;
   call execute( '%nrstr( %%let drop_list= )' ) ; &lt;BR /&gt;
      do _n_ = 1 to dim(chrs)-1 ;&lt;BR /&gt;
         if ^chrsc(_n_) then call execute( vName( chrs(_N_) ) ) ;&lt;BR /&gt;
      end;&lt;BR /&gt;
      do _n_ = 1 to dim(nums)-1 ;&lt;BR /&gt;
         if ^numsc(_n_) then call execute( vName( nums(_N_) ) ) ;&lt;BR /&gt;
      end;&lt;BR /&gt;
      call execute( ' ; '   ) ;       &lt;BR /&gt;
   end;&lt;BR /&gt;
   &lt;BR /&gt;
***** removing empty rows &lt;BR /&gt;
   if n( of nums(*) ) le 1 then do; * no numerics so check chrs ;&lt;BR /&gt;
      if catt( of chrs(*) ) = ' ' then delete ;&lt;BR /&gt;
   end;       &lt;BR /&gt;
run;&lt;BR /&gt;
 &lt;BR /&gt;
* finally apply that drop list ;   &lt;BR /&gt;
data reduced_rows_and_cols ;&lt;BR /&gt;
    set reduced_rows( drop= &amp;amp;drop_list );&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
try that ;&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Fri, 23 May 2008 12:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20233#M3134</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-23T12:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20234#M3135</link>
      <description>Hi Peter_c,&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your code. Itried but it is not working. The log shows:&lt;BR /&gt;
&lt;BR /&gt;
120  data readin ;&lt;BR /&gt;
121&lt;BR /&gt;
122     set inf1.'Insurance Serv-Quest$a1:iv64000'n;&lt;BR /&gt;
123   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 277 observations read from the data set INF1.'Insurance&lt;BR /&gt;
      Serv-Quest$a1:iv64000'n.&lt;BR /&gt;
NOTE: The data set WORK.READIN has 277 observations and 10 variables.&lt;BR /&gt;
NOTE: Compressing data set WORK.READIN decreased size by 96.77 percent.&lt;BR /&gt;
      Compressed is 3 pages; un-compressed would require 93 pages.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.03 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
124&lt;BR /&gt;
125  proc contents data=readin  ; run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: PROCEDURE CONTENTS used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
126&lt;BR /&gt;
127&lt;BR /&gt;
128&lt;BR /&gt;
129  libname _all_ clear ;&lt;BR /&gt;
NOTE: Libref FIN has been deassigned.&lt;BR /&gt;
NOTE: Libref INF1 has been deassigned.&lt;BR /&gt;
129!                      run;&lt;BR /&gt;
&lt;BR /&gt;
130  options compress=yes mprint mlogic symbolgen;&lt;BR /&gt;
131&lt;BR /&gt;
132  libname fin 'c:\' ;&lt;BR /&gt;
NOTE: Libref FIN was successfully assigned as follows:&lt;BR /&gt;
      Engine:        V9&lt;BR /&gt;
      Physical Name: c:\&lt;BR /&gt;
133&lt;BR /&gt;
134  libname inf1 odbc noprompt=XXXXX&lt;BR /&gt;
135  C:\temp\Experian Subcodes.xls;&lt;BR /&gt;
136  Deleted=1;Driver={Microsoft excel Driver (*.xls)};ReadOnly=0";&lt;BR /&gt;
NOTE: Libref INF1 was successfully assigned as follows:&lt;BR /&gt;
      Engine:        ODBC&lt;BR /&gt;
      Physical Name:&lt;BR /&gt;
137&lt;BR /&gt;
138  data readin ;&lt;BR /&gt;
139&lt;BR /&gt;
140     set inf1.'Insurance Serv-Quest$a1:iv64000'n;&lt;BR /&gt;
141   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 277 observations read from the data set INF1.'Insurance&lt;BR /&gt;
      Serv-Quest$a1:iv64000'n.&lt;BR /&gt;
NOTE: The data set WORK.READIN has 277 observations and 10 variables.&lt;BR /&gt;
NOTE: Compressing data set WORK.READIN decreased size by 96.77 percent.&lt;BR /&gt;
      Compressed is 3 pages; un-compressed would require 93 pages.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.03 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
142&lt;BR /&gt;
143  proc contents data=readin  ; run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: PROCEDURE CONTENTS used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
144&lt;BR /&gt;
145  data reduced_rows( drop= empty) ;&lt;BR /&gt;
146  retain empty ' ' ;&lt;BR /&gt;
147  array nums(*) _numeric_ _n_ ; * have at least one numeric ;&lt;BR /&gt;
148  array chrs(*) _character_ empty ;**** mark non-empty columns ;&lt;BR /&gt;
149  array numsc(1000) _temporary_; * assume have no more than 1000 num var ;&lt;BR /&gt;
150  array chrsc(1000) _temporary_; * assume have no more than 1000 chr var ;&lt;BR /&gt;
151&lt;BR /&gt;
152  set readin end= eof;&lt;BR /&gt;
153&lt;BR /&gt;
154     do _n_ = 1 to dim(nums) ;&lt;BR /&gt;
155         numsc(_n_) + ^missing( nums(_n_)) ;&lt;BR /&gt;
156     end;&lt;BR /&gt;
157&lt;BR /&gt;
158      do _n_ = 1 to dim(chrs) ;&lt;BR /&gt;
159         chrsc(_n_) + ^missing( chrs(_n_)) ;&lt;BR /&gt;
160      end;&lt;BR /&gt;
161&lt;BR /&gt;
162  **** after looking through all data, prepare a drop list for empty columns ;&lt;BR /&gt;
163   if eof then do;&lt;BR /&gt;
164      %let drop_list= ; *ensure prepared and empty by default;&lt;BR /&gt;
165           call execute( '%nrstr( %%let drop_list= )' ) ;&lt;BR /&gt;
166&lt;BR /&gt;
167     do _n_ = 1 to dim(chrs)-1 ;&lt;BR /&gt;
168        if ^chrsc(_n_) then call execute( vName( chrs(_N_) ) ) ;&lt;BR /&gt;
169     end;&lt;BR /&gt;
170&lt;BR /&gt;
171     do _n_ = 1 to dim(nums)-1 ;&lt;BR /&gt;
172       if ^numsc(_n_) then call execute( vName( nums(_N_) ) ) ;&lt;BR /&gt;
173     end;&lt;BR /&gt;
174        call execute( ' ; '   ) ;&lt;BR /&gt;
175&lt;BR /&gt;
176    end;&lt;BR /&gt;
177          ***** removing empty rows ;&lt;BR /&gt;
178&lt;BR /&gt;
179       if n( of nums(*) ) le 1 then do; * no numerics so check chrs ;&lt;BR /&gt;
180             if catt( of chrs(*) ) = ' ' then delete ;&lt;BR /&gt;
181       end;&lt;BR /&gt;
182  run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 277 observations read from the data set WORK.READIN.&lt;BR /&gt;
NOTE: The data set WORK.REDUCED_ROWS has 0 observations and 10 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.07 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
NOTE: CALL EXECUTE generated line.&lt;BR /&gt;
182!      * finally apply that drop list ;&lt;BR /&gt;
1   +    %let drop_list=&lt;BR /&gt;
2   + empty&lt;BR /&gt;
3   +  ;&lt;BR /&gt;
183&lt;BR /&gt;
184  data reduced_rows_and_cols ;&lt;BR /&gt;
185      set reduced_rows(&lt;BR /&gt;
SYMBOLGEN:  Macro variable DROP_LIST resolves to empty&lt;BR /&gt;
185!                       drop= &amp;amp;drop_list );&lt;BR /&gt;
ERROR: The variable empty in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;
186  run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Compression was disabled for data set WORK.REDUCED_ROWS_AND_COLS because compression&lt;BR /&gt;
      overhead would increase the size of the data set.&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
WARNING: The data set WORK.REDUCED_ROWS_AND_COLS may be incomplete.  When this step was stopped&lt;BR /&gt;
         there were 0 observations and 0 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
187&lt;BR /&gt;
188&lt;BR /&gt;
189&lt;BR /&gt;
190&lt;BR /&gt;
191  libname _all_ clear ;&lt;BR /&gt;
NOTE: Libref FIN has been deassigned.&lt;BR /&gt;
NOTE: Libref INF1 has been deassigned.&lt;BR /&gt;
191!                      run;&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Fri, 23 May 2008 13:24:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20234#M3135</guid>
      <dc:creator>Kwok</dc:creator>
      <dc:date>2008-05-23T13:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20235#M3136</link>
      <description>&amp;gt; Yes, we do read in Excel spreadsheets.&lt;BR /&gt;
&amp;gt; If your code is correct, it will drop all the columns&lt;BR /&gt;
&amp;gt; and all the rows properly.&lt;BR /&gt;
&lt;BR /&gt;
I find that within a spreadsheet if all the cell values in a column/row was delete without deleting the column/row, then SAS will read in the coulmn as a valid SAS variable and the row as valid obs even they are both total empty. So if I was handed a spreadsheet to read into SAS without knowing some of the column/row were previous non blank. How can I instruct SAS not to read those empty but previously non-empty column/row ?&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Fri, 23 May 2008 13:54:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20235#M3136</guid>
      <dc:creator>Kwok</dc:creator>
      <dc:date>2008-05-23T13:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20236#M3137</link>
      <description>Can't, you'll have to filter those out after the fact.&lt;BR /&gt;
That is, you will have to filter the empty rows while reading in the data, and then filter out empty columns later.&lt;BR /&gt;
&lt;BR /&gt;
We use Excel spreadsheets as a simple mechanism to hold configuration information.  It is easy to edit and print the information.  The first row contains the field names, and all non-used rows and columns are "deleted" or "empty" so that SAS considers them "missing" and doesn't read them.  Since the first row contains the field names, SAS automatically assigns variables (variable names and labels) to those columns, and all subsequent rows are read in as data.  Our code then assumes specific column names.  If you are being handed amorphous Excel spreadsheets, then your job is going to be a lot harder, but I would also question as to "why?" what is the purpose?  The point of SAS is to do data analysis against either massive amounts of data, or in very sophisticated manners, perhaps applying highly sophisticated (and preprogrammed in "proc"s) analyses to the data.  If the input are unknown Excel spreadsheets, then how is the system going to know what to do with the data?

Message was edited by: Chuck</description>
      <pubDate>Mon, 26 May 2008 15:36:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20236#M3137</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-26T15:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20237#M3138</link>
      <description>Thanks. Appricate for your comments</description>
      <pubDate>Tue, 27 May 2008 14:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20237#M3138</guid>
      <dc:creator>Kwok</dc:creator>
      <dc:date>2008-05-27T14:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20238#M3139</link>
      <description>I have two suggestions, one manual and one hopefully automated.&lt;BR /&gt;
&lt;BR /&gt;
Manual Solution:&lt;BR /&gt;
When you get an Excel file and find these empty columns occurring in your SAS import, then open up the Excel file in MS Excel and delete the empty columns (don't just delete the cells again, actually delete the column).  Resave the file and SAS should work better.&lt;BR /&gt;
&lt;BR /&gt;
Automated Solution:&lt;BR /&gt;
From one of the earlier posts, it was mentioned that SAS assigns it's own column names (e.g. F2, F3, . . . ) to the blank columns.  Maybe you can just drop all the column names that fit this format.  For example.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data imported;&lt;BR /&gt;
	infile cards missover;&lt;BR /&gt;
	input FirstCol SecondCol F1 F2 F3;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 2&lt;BR /&gt;
3 4&lt;BR /&gt;
5 6&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data cleaned;&lt;BR /&gt;
   set imported;&lt;BR /&gt;
   drop F1 - F256; *Drop any columns that start with 'F' followed by a number up to 256;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Be careful not to drop valid column names that start with 'F' in this example.  You might have to tweak your column names to handle this properly.</description>
      <pubDate>Thu, 29 May 2008 21:51:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20238#M3139</guid>
      <dc:creator>1162</dc:creator>
      <dc:date>2008-05-29T21:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20239#M3140</link>
      <description>Proc Format  &lt;BR /&gt;
  CntLOout = Control ;&lt;BR /&gt;
   Value NMis  &lt;BR /&gt;
        . - .z  =  ' ‘&lt;BR /&gt;
        Other = '1'  ;&lt;BR /&gt;
   &lt;BR /&gt;
   Value $NMis &lt;BR /&gt;
         ' '   =  ' ' &lt;BR /&gt;
     Other = '1' ;&lt;BR /&gt;
Run ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
ODS Listing Close;&lt;BR /&gt;
ODS Output OneWayFreqs = Freqs ( Where = ( Frequency = CumFrequency ) ) ;&lt;BR /&gt;
&lt;BR /&gt;
Proc Freq &lt;BR /&gt;
  Data = Test ;&lt;BR /&gt;
  Table _All_ / Missing ;&lt;BR /&gt;
  Format _Numeric_   NMis. &lt;BR /&gt;
              _Character_ $NMis. ;&lt;BR /&gt;
  Run ;&lt;BR /&gt;
ODS Listing;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Data Missing ( Keep = Var ) ;&lt;BR /&gt;
Length Var $ 32 ;&lt;BR /&gt;
Format _All_ ;&lt;BR /&gt;
Set Freqs;&lt;BR /&gt;
&lt;BR /&gt;
If ( Percent = 100 ) ;&lt;BR /&gt;
   &lt;BR /&gt;
Var = Scan( Table , -1 , ' ' ) ;&lt;BR /&gt;
   &lt;BR /&gt;
If Missing( VValueX( Var ) ) ;&lt;BR /&gt;
&lt;BR /&gt;
Run ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Proc SQL NoPrint ;&lt;BR /&gt;
Select Var Into : DropVars Separated By ' '&lt;BR /&gt;
  From Missing ;&lt;BR /&gt;
Quit ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Data Test ;&lt;BR /&gt;
Set Test ( Drop = &amp;amp;DropVars ) ;&lt;BR /&gt;
Run ;</description>
      <pubDate>Thu, 26 Jun 2008 17:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20239#M3140</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-26T17:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20240#M3141</link>
      <description>Another possible method would be to use PROC TRANSPOSE.&lt;BR /&gt;
&lt;BR /&gt;
First read all the rows and eliminate all blank rows which can be easily achieved, as suggested by Chuck.&lt;BR /&gt;
&lt;BR /&gt;
The you can use PROC TRASNPOSE which will convert the columns into rows, so again you have the same problem of eliminating blank rows. That being done you can transpose again to get back your original data.&lt;BR /&gt;
&lt;BR /&gt;
A bit of attention should be paid while handling the header rows, that is all.</description>
      <pubDate>Fri, 27 Jun 2008 06:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20240#M3141</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-27T06:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20241#M3142</link>
      <description>When I saw Toby mentionning the Freq procedure, I thought it will save time to use the new (version 9) NLEVELS option to automate discarding empty variables. For the empty rows, count non-missing numeric values and test whether the concatenation of all character variables is empty to control deletion.&lt;BR /&gt;
[pre]&lt;BR /&gt;
DATA work.empty_spaces ;&lt;BR /&gt;
	INFILE CARDS MISSOVER DSD DLM=" " ;&lt;BR /&gt;
	INPUT v1 v2 $ v3 v4 ;&lt;BR /&gt;
CARDS ;&lt;BR /&gt;
1 1 1&lt;BR /&gt;
1 2 1&lt;BR /&gt;
1 3 1&lt;BR /&gt;
.   .&lt;BR /&gt;
;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
ODS EXCLUDE ALL ;&lt;BR /&gt;
ODS OUTPUT nLevels = work.levels ;&lt;BR /&gt;
PROC FREQ DATa = work.empty_spaces NLEVELS ;&lt;BR /&gt;
	TABLE _ALL_ / NOPRINT ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
ODS SELECT ALL ;&lt;BR /&gt;
PROC SQL NOPRINT ;&lt;BR /&gt;
	SELECT tableVar INTO : empty_vars SEPARATED BY " "&lt;BR /&gt;
	FROM work.levels&lt;BR /&gt;
	WHERE NNonMissLevels = 0&lt;BR /&gt;
	;&lt;BR /&gt;
QUIT ;&lt;BR /&gt;
DATA work.just_data ;&lt;BR /&gt;
	SET work.empty_spaces (DROP = &amp;amp;empty_vars) ;&lt;BR /&gt;
	IF N(OF _NUMERIC_) = 0 AND MISSING(COMPRESS(CATS(OF _CHARACTER_))) THEN DELETE ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Regards.&lt;BR /&gt;
Olivier</description>
      <pubDate>Fri, 27 Jun 2008 07:28:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20241#M3142</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-06-27T07:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting  blank variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20242#M3143</link>
      <description>Thanks for your suggestion. However, the problem is that some of the original valid heading has a numeric value( like 12,24,etc. ) and SAS automatic add an 'F' to these columns. Then your automate method will not work unless the automatic letter 'F' can be changed to other letter duning the read in process. I have been using the manual method but it's a pain when you have to do with so multiple books and multiple sheets.</description>
      <pubDate>Fri, 27 Jun 2008 12:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Detecting-blank-variables/m-p/20242#M3143</guid>
      <dc:creator>Kwok</dc:creator>
      <dc:date>2008-06-27T12:02:32Z</dc:date>
    </item>
  </channel>
</rss>

