<?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 Invalid Data Error on Set with Atypical Blanks in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Error-on-Set-with-Atypical-Blanks/m-p/584342#M166412</link>
    <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to upload a large set from a .txt file. If numeric data does not exist in a cell it has been filled in with '--' so SAS is getting confused when trying to read in my numeric variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA ID2175;
	infile 'C:\Documents\2175.Txt' firstobs = 2;
	input Days 1-4 @6 Date mmddyy10. @17 Milk @23 Cond @29 AMT @34 Activity @43 Weight;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have tried using both missover and compress, but with both I still get the error below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Invalid data for Milk in line 20 17-22.
NOTE: Invalid data for Cond in line 20 23-24.
NOTE: Invalid data for AMT in line 20 29-30.
NOTE: Invalid data for Activity in line 20 34-35.
NOTE: Invalid data for Weight in line 20 43-44.

20  CHAR  18  .06/18/2012.--   .--   .--  .--      .--    . 49
    ZONE  3322033233233330222220222220222202222222202222220
    NUMR  1800906F18F20129DD0009DD0009DD009DD0000009DD00009
Days=18 Date=06/18/2012 Milk=. Cond=. AMT=. Activity=. Weight=. _ERROR_=1 _N_=19&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any recommendations how I can correct this? Ideally I would replace -- with . to make a blank SAS recognized but I haven't been able to do this with an if/then statement either.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Aug 2019 19:49:10 GMT</pubDate>
    <dc:creator>bonedog</dc:creator>
    <dc:date>2019-08-27T19:49:10Z</dc:date>
    <item>
      <title>Invalid Data Error on Set with Atypical Blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Error-on-Set-with-Atypical-Blanks/m-p/584342#M166412</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to upload a large set from a .txt file. If numeric data does not exist in a cell it has been filled in with '--' so SAS is getting confused when trying to read in my numeric variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA ID2175;
	infile 'C:\Documents\2175.Txt' firstobs = 2;
	input Days 1-4 @6 Date mmddyy10. @17 Milk @23 Cond @29 AMT @34 Activity @43 Weight;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have tried using both missover and compress, but with both I still get the error below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Invalid data for Milk in line 20 17-22.
NOTE: Invalid data for Cond in line 20 23-24.
NOTE: Invalid data for AMT in line 20 29-30.
NOTE: Invalid data for Activity in line 20 34-35.
NOTE: Invalid data for Weight in line 20 43-44.

20  CHAR  18  .06/18/2012.--   .--   .--  .--      .--    . 49
    ZONE  3322033233233330222220222220222202222222202222220
    NUMR  1800906F18F20129DD0009DD0009DD009DD0000009DD00009
Days=18 Date=06/18/2012 Milk=. Cond=. AMT=. Activity=. Weight=. _ERROR_=1 _N_=19&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any recommendations how I can correct this? Ideally I would replace -- with . to make a blank SAS recognized but I haven't been able to do this with an if/then statement either.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 19:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Error-on-Set-with-Atypical-Blanks/m-p/584342#M166412</guid>
      <dc:creator>bonedog</dc:creator>
      <dc:date>2019-08-27T19:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Data Error on Set with Atypical Blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Error-on-Set-with-Atypical-Blanks/m-p/584357#M166424</link>
      <description>&lt;P&gt;Proc format with a custom informat to rescue:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
invalue mymess
'--'=.
other= [best32.];
run;

data example;
   input x :mymess.;
datalines;
1
123
1.4E8
--
.0000123
123.456789
;
run;&lt;/PRE&gt;
&lt;P&gt;The above assigns the SAS missing value. Other values could be assigned is that seemed to make sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Easiest might be to add in INFORMAT statement to you data step such as&lt;/P&gt;
&lt;PRE&gt;informat Milk  Cond AMT  Activity Weight mymess.;&lt;/PRE&gt;
&lt;P&gt;prior to the input statement.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 20:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Error-on-Set-with-Atypical-Blanks/m-p/584357#M166424</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-27T20:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Data Error on Set with Atypical Blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Error-on-Set-with-Atypical-Blanks/m-p/584364#M166433</link>
      <description>With a couple extra informats this worked! Thanks!</description>
      <pubDate>Tue, 27 Aug 2019 20:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Error-on-Set-with-Atypical-Blanks/m-p/584364#M166433</guid>
      <dc:creator>bonedog</dc:creator>
      <dc:date>2019-08-27T20:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Data Error on Set with Atypical Blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Error-on-Set-with-Atypical-Blanks/m-p/584368#M166436</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282450"&gt;@bonedog&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;With a couple extra informats this worked! Thanks!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I was kind of wondering if there were different lengths of -- and ------ or such in the actual data for different variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Informats are VERY powerful once you get the idea down.&amp;nbsp;I use them for text that should be consistent but the data providers will randomly insert characters or change agreed upon values like "NA" to "N/A". I use custom informats to read the expected values and use an "other=_error_" as the last element of the format. That way I get errors thrown in the log and can modify the Informat so that both "NA" and "N/A" get mapped to the same code value in the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 20:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Error-on-Set-with-Atypical-Blanks/m-p/584368#M166436</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-27T20:58:52Z</dc:date>
    </item>
  </channel>
</rss>

