<?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: Input data with Invalid data error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356779#M83703</link>
    <description>&lt;P&gt;1) put the %LET statement out in before the data step&lt;/P&gt;
&lt;P&gt;2) You defined INFORMAT of some variables longer then the real informat&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;e.g. informat of mkt_rf $12. while text is probably 0.10 - just length of 4&lt;/P&gt;
&lt;P&gt;3) You defined delimiter = ';' while given input has no semi-colon at all&lt;/P&gt;
&lt;P&gt;4) Did you got invalid date from line 2 on ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try next code:&lt;/P&gt;
&lt;PRE&gt;%let _EFIERR_ = 0; /* set the ERROR detection macro variable */

data fff ;
infile 'C:\Sirimon\ha\Data\F-F_Research_Data_Factors_daily_csv\F-F_Research_Data_Factors_daily.csv' delimiter=';' truncover DSD lrecl=32767 firstobs=6 ;

format Date yymmdd8.
mkt_rf $12.
smb $12.
rf $12.;

input
Date yymmdd8.
mkt_rf
smb
rf
;&lt;/PRE&gt;
&lt;P&gt;Do you still get INVALID DATE ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the input (few lines) as you realy heve it and post your full log.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 May 2017 04:54:43 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-05-08T04:54:43Z</dc:date>
    <item>
      <title>Input data with Invalid data error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356775#M83700</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to import data from txt file or csv as follow.&lt;/P&gt;
&lt;P&gt;Date Mkt-RF SMB HML RF&lt;BR /&gt;19260701 0.10 -0.24 -0.28 0.009&lt;BR /&gt;19260702 0.45 -0.32 -0.08 0.009&lt;BR /&gt;19260706 0.17 0.27 -0.35 0.009&lt;BR /&gt;19260707 0.09 -0.59 0.03 0.009&lt;BR /&gt;19260708 0.21 -0.36 0.15 0.009&lt;BR /&gt;19260709 -0.71 0.44 0.56 0.009&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code I tried is invalid data with date, even I try different formats for date but it can not run. And I am not sure for the format of mkt-rf, smb, hml, rf are right or not, they should be numeric as interest rate.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help. Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fff ;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile 'C:\Sirimon\ha\Data\F-F_Research_Data_Factors_daily_csv\F-F_Research_Data_Factors_daily.csv' delimiter=';' MISSOVER DSD lrecl=32767 firstobs=6 ;


informat Date yymmdd8.
mkt_rf $12.
smb $12.
rf $12. ;


format Date yymmdd8.
mkt_rf $12.
smb $12.
rf $12.;


input
Date
mkt_rf
smb
rf
;
if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 05:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356775#M83700</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2017-05-08T05:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Input data with Invalid data error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356777#M83701</link>
      <description>&lt;P&gt;Your data, as shown, didn't have any delimiter other than a space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your infile statement indicated that the first data line was line 6 but, your example, had it as line 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your input statement only inputted 4 variables, while you had 5. And, other than the dates, you were inputting numbers as characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I presume you want something like:&lt;/P&gt;
&lt;PRE&gt;data fff ;
  infile 'C:\art\F-F_Research_Data_Factors_daily.txt' truncover lrecl=32767 firstobs=2 ;
  informat Date yymmdd8.;
  format Date yymmdd10.;
  input Date mkt_rf smb hml rf;
run;  
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 04:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356777#M83701</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-08T04:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Input data with Invalid data error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356779#M83703</link>
      <description>&lt;P&gt;1) put the %LET statement out in before the data step&lt;/P&gt;
&lt;P&gt;2) You defined INFORMAT of some variables longer then the real informat&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;e.g. informat of mkt_rf $12. while text is probably 0.10 - just length of 4&lt;/P&gt;
&lt;P&gt;3) You defined delimiter = ';' while given input has no semi-colon at all&lt;/P&gt;
&lt;P&gt;4) Did you got invalid date from line 2 on ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try next code:&lt;/P&gt;
&lt;PRE&gt;%let _EFIERR_ = 0; /* set the ERROR detection macro variable */

data fff ;
infile 'C:\Sirimon\ha\Data\F-F_Research_Data_Factors_daily_csv\F-F_Research_Data_Factors_daily.csv' delimiter=';' truncover DSD lrecl=32767 firstobs=6 ;

format Date yymmdd8.
mkt_rf $12.
smb $12.
rf $12.;

input
Date yymmdd8.
mkt_rf
smb
rf
;&lt;/PRE&gt;
&lt;P&gt;Do you still get INVALID DATE ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the input (few lines) as you realy heve it and post your full log.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 04:54:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356779#M83703</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-05-08T04:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Input data with Invalid data error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356780#M83704</link>
      <description>&lt;P&gt;You are tryiing to get Fama-French factors into a SAS data set.&amp;nbsp; I see a number of issues:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You name the file as if it is&amp;nbsp;comma-separated, but the data are actually space separated and your DLM= option specifies a ':'.&lt;/LI&gt;
&lt;LI&gt;You are reading the factor values as character, they should be numeric&lt;/LI&gt;
&lt;LI&gt;You have "FIRSTOBS=6". Why?&amp;nbsp; It looks like you should have FIRSTOBS=2&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Consider this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fff ;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile ''C:\Sirimon\ha\Data\F-F_Research_Data_Factors_daily_csv\F-F_Research_Data_Factors_daily.csv'&amp;nbsp;&lt;BR /&gt;      delimiter=' ' MISSOVER DSD lrecl=32767  firstobs=2;
informat Date yymmdd8.
         mkt_rf 12.
         smb 12.
         rf 12. ;
format Date yymmdd8.
         mkt_rf 12.4
         smb 12.4
         rf 12.4;
input Date mkt_rf smb rf ;
if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I presume you are getting the data from Ken French's web site, so there should be no missing values.&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 05:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356780#M83704</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-05-08T05:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Input data with Invalid data error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356790#M83709</link>
      <description>&lt;P&gt;This will read your data OK.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile cards firstobs=2;
input Date :yymmdd8. Mkt_RF SMB HML RF;
format Date yymmddn8.;
cards;
Date Mkt-RF SMB HML RF
19260701 0.10 -0.24 -0.28 0.009
19260702 0.45 -0.32 -0.08 0.009
19260706 0.17 0.27 -0.35 0.009
19260707 0.09 -0.59 0.03 0.009
19260708 0.21 -0.36 0.15 0.009
19260709 -0.71 0.44 0.56 0.009
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Assuming that the data is as posted (I did a copy-paste to my EG program window). In the future use the {i} button to post log or data text, as it will preserve all characters and the formatting.&lt;/P&gt;
&lt;P&gt;Note that I copied the variable names from the first line, with the only change being the replacement of the dash by an underline.&lt;/P&gt;
&lt;P&gt;Think simple; your code is too complicated. Only add options when needed.&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 06:50:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-data-with-Invalid-data-error/m-p/356790#M83709</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-08T06:50:56Z</dc:date>
    </item>
  </channel>
</rss>

