<?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: Error importing line in CSV (Invalid data for *variable* in line *line column_range*) in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410501#M26322</link>
    <description>&lt;P&gt;Looking at the line that it is failing on it is show way more that 19 items on one line.&lt;/P&gt;
&lt;P&gt;It is also show&amp;nbsp;end of line mark ('0D0A'x) in the middle of line.&lt;/P&gt;
&lt;P&gt;Are you sure that data file is using UTF-16 encoding?&amp;nbsp; If so it should NOT have&amp;nbsp;&lt;SPAN&gt;'0D0A'x as that is an invalid 16 bit code.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 04 Nov 2017 01:12:27 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-11-04T01:12:27Z</dc:date>
    <item>
      <title>Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410193#M26296</link>
      <description>&lt;P&gt;I'm on SAS Enterprise Guide 7.11, SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When trying to import a csv file, there's a line that disappears. It is the one mentioned in the error below.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16396i0CE27EE02E920BE6/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(See block quote of this at the bottom of this question).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've opened the file in Notepad++, but can't find anything wrong with the missing line.&lt;/P&gt;&lt;P&gt;Here's a screen shot placed at the missing line at column 283 (where SAS claims the error begins):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16397i0FA44EF367F52317/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm using is&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Want;
    Length
        'Nº de Operación de Venta C&amp;amp;C'n $ 29
        "Estado Operación"n $ 46
        "Código de Pedido"n   8
        "Estado del Pedido"n $ 46
        "Fecha de Pedido"n   8
        "Hora de Pedido"n   8
        "Referencia ECI"n $ 18
        "Descripción Referencia ECI"n $ 40
        "División"n      $ 5
        "Descripción División"n $ 20
        "Subdivisión"n   $ 7
        "Descripción Subdivisión"n $ 20
        "Método de Envío"n $ 16
        "Fecha de Compromiso Original"n   8
        "Fecha de Compromiso"n   8
        "Importe Original"n $ 10
        Importe          $ 10
        Unidades           8
        "Unidades Pedidas"n   8;
    Format
        'Nº de Operación de Venta C&amp;amp;C'n $CHAR29.
        "Estado Operación"n $CHAR46.
        "Código de Pedido"n BEST13.
        "Estado del Pedido"n $CHAR46.
        "Fecha de Pedido"n Date9.
        "Hora de Pedido"n TIME8.
        "Referencia ECI"n $CHAR18.
        "Descripción Referencia ECI"n $CHAR40.
        "División"n      $CHAR5.
        "Descripción División"n $CHAR20.
        "Subdivisión"n   $CHAR7.
        "Descripción Subdivisión"n $CHAR20.
        "Método de Envío"n $CHAR16.
        "Fecha de Compromiso Original"n DATE9.
        "Fecha de Compromiso"n DATE9.
        "Importe Original"n $CHAR10.
        Importe          $CHAR10.
        Unidades         Comma12.
        "Unidades Pedidas"n Comma12.;
    Informat
        'Nº de Operación de Venta C&amp;amp;C'n $CHAR29.
        "Estado Operación"n $CHAR46.
        "Código de Pedido"n BEST13.
        "Estado del Pedido"n $CHAR46.
        "Fecha de Pedido"n Date9.
        "Hora de Pedido"n TIME8.
        "Referencia ECI"n $CHAR18.
        "Descripción Referencia ECI"n $CHAR40.
        "División"n      $CHAR5.
        "Descripción División"n $CHAR20.
        "Subdivisión"n   $CHAR7.
        "Descripción Subdivisión"n $CHAR20.
        "Método de Envío"n $CHAR16.
        "Fecha de Compromiso Original"n DATE9.
        "Fecha de Compromiso"n DATE9.
        "Importe Original"n $CHAR10.
        Importe          $CHAR10.
        Unidades         Comma12.
        "Unidades Pedidas"n Comma12.;
    Infile "file_path_name"
        Firstobs=2
        LRECL=600
        ENCODING="UTF-16"
        TERMSTR=CRLF
        DLM=","
        MISSOVER
        DSD;
    Input
        'Nº de Operación de Venta C&amp;amp;C'n : $CHAR29.
        "Estado Operación"n : $CHAR46.
        "Código de Pedido"n :  BEST13.
        "Estado del Pedido"n : $CHAR46.
        "Fecha de Pedido"n :  MMDDYY10.
        "Hora de Pedido"n :  TIME5.
        "Referencia ECI"n : $CHAR18.
        "Descripción Referencia ECI"n : $CHAR40.
        "División"n      : $CHAR5.
        "Descripción División"n : $CHAR20.
        "Subdivisión"n   : $CHAR7.
        "Descripción Subdivisión"n : $CHAR20.
        "Método de Envío"n : $CHAR16.
        "Fecha de Compromiso Original"n :  YYMMDD10.
        "Fecha de Compromiso"n :  MMDDYY10.
        "Importe Original"n : $CHAR10.
        Importe          : $CHAR10.
        Unidades         :  Comma12.
        "Unidades Pedidas"n :  Comma12.;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;NOTE: Invalid data for 'Unidades Pedidas'n in line 10524 283-318.
REGLA: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
10524 "00401430761020520170823225656","Cancelled","1723549001754","Cancelled","8/23/2017","22:57 ","001002
101 535973537 ","SET PULSERAS 4 ","00102","COMPLEMENTOS ","0010258","B
201 ISUTERIA ","HomeDelivery","2017-09-07","9/7/2017","4.45 €","0.00 €","1","0".."004014307610
ZONE 4555454422222222222222466646667677222333323323322232323333222323328222323328222322232002333333333333
NUMR 93545291000000000002C28FD545C965292C22017D09D072C29F7F20172C24E45002C20E00002C212C202DA2004014307610
301 20520170823225656","Cancelled","1723549001754","Cancelled","8/23/2017","22:57 ","001016687233862042"
401 ,"CMST E/RE N/C COMB. LUREX ","00109","JOVEN ELLA ","0010919","MARCAS PRO.JOV
501 EN E ","HomeDelivery","2017-09-07","9/7/2017","2.99 €","0.00 €","1","0" 572
'Nº de Operación de Venta C&amp;amp;C'n=00401430761020520170823225656 'Estado Operación'n=Cancelled 'Código de Pedido'n=1723549001754
'Estado del Pedido'n=Cancelled 'Fecha de Pedido'n=23AUG2017 'Hora de Pedido'n=22:57:00 'Referencia ECI'n=001002535973537
'Descripción Referencia ECI'n=SET PULSERAS 4 'División'n=00102 'Descripción División'n=COMPLEMENTOS 'Subdivisión'n=0010258
'Descripción Subdivisión'n=BISUTERIA 'Método de Envío'n=HomeDelivery 'Fecha de Compromiso Original'n=07SEP2017
'Fecha de Compromiso'n=07SEP2017 'Importe Original'n=4.45 € Importe=0.00 € Unidades=1 'Unidades Pedidas'n=. _ERROR_=1 _N_=10523&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sat, 04 Nov 2017 09:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410193#M26296</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2017-11-04T09:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410198#M26299</link>
      <description>&lt;P&gt;PLEASE!!!!&lt;/P&gt;
&lt;P&gt;post logs in the {i} subwindow, so horizontal spacing is preserved!&lt;/P&gt;
&lt;P&gt;The main posting window mangles such content into uselessness by removing blanks etc.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 13:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410198#M26299</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-03T13:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410223#M26304</link>
      <description>&lt;P&gt;If you are using PROC IMPORT , try option&amp;nbsp; GUESSINGROW=max&amp;nbsp; .&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 13:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410223#M26304</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-03T13:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410226#M26306</link>
      <description>&lt;P&gt;And post the code used to attempt that read.&lt;/P&gt;
&lt;P&gt;The error you are getting is usually related to the informat associated with a variable. HOW that informat is specified can cause issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also your picture shows a small vertical purple line. Did you add that? If not, it is likely whatever that represents is the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 14:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410226#M26306</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-03T14:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410388#M26310</link>
      <description>&lt;P&gt;I added the code. The vertical purple line isn't a character, it's the&amp;nbsp;spot where I placed the cursor.&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 18:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410388#M26310</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2017-11-03T18:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410501#M26322</link>
      <description>&lt;P&gt;Looking at the line that it is failing on it is show way more that 19 items on one line.&lt;/P&gt;
&lt;P&gt;It is also show&amp;nbsp;end of line mark ('0D0A'x) in the middle of line.&lt;/P&gt;
&lt;P&gt;Are you sure that data file is using UTF-16 encoding?&amp;nbsp; If so it should NOT have&amp;nbsp;&lt;SPAN&gt;'0D0A'x as that is an invalid 16 bit code.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 01:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410501#M26322</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-04T01:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410521#M26328</link>
      <description>How do you identify the end of line mark? I can't find it. But, judging by the log and my knowledge of the data, it should be the two consecutive full stops in the line above "ZONE 4555454422222222222222466646667677222333323323322232323333222323328222323328222322232002333333333333".&lt;BR /&gt;No, I'm not sure about the encoding. I can't remember at the moment (and also can't check), but I think I copied the encoding from what SAS EG chose when I manually imported the file. Also, Notepad++ seems to support this.&lt;BR /&gt;Is there a way to get an "official" answer to what the encoding is?</description>
      <pubDate>Sat, 04 Nov 2017 10:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410521#M26328</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2017-11-04T10:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410532#M26329</link>
      <description>&lt;P&gt;At the circled point in the attached, instead of the "0" being followed by a comma, it is being followed by the hex characters "2080". Because of the lack of a comma, SAS is interpreting everything to the right as part of the field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to get those two hex characters out of there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Flagged.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16435iF378F7BFD9E79DEF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Flagged.png" alt="Flagged.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 13:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410532#M26329</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-11-04T13:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410536#M26330</link>
      <description>But at the point a line ends, it's supposed to be a "CRLF" and that's what I see in Notepad++. Am I misinterpreting something here?</description>
      <pubDate>Sat, 04 Nov 2017 13:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410536#M26330</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2017-11-04T13:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410546#M26333</link>
      <description>&lt;P&gt;How many lines does notepad+ see in the file?&lt;/P&gt;
&lt;P&gt;Now count how many lines SAS sees if you don't add anything to the INFILE statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "file_path_name";
  input;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If they are the same then leave most of those other things off the INFILE statement.&amp;nbsp; If you are running Unix and the carriage returns mess up the last field there are other ways to deal with it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  infile "file_path_name" dsd truncover firstobs=2;
  length var1-var19 $50 ;
  input var1-var19 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to see what is in file read it as binary and look.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "file_path_name" recfm=f lrecl=100 obs=20 encoding='any';
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 15:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410546#M26333</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-04T15:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410564#M26340</link>
      <description>Notepad++ sees as many lines as SAS reports after I run the first of the snippets above: NOTE: 16813 records were read from the infile&lt;BR /&gt;However this number doesn't correspond to the number of CRLFs in the file.&lt;BR /&gt;I expect to have 16809 observations (as many CRLFs as there are in the file).</description>
      <pubDate>Sat, 04 Nov 2017 17:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410564#M26340</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2017-11-04T17:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410568#M26341</link>
      <description>If you expect fewer lines than SAS and NOTEPAD+ are reporting then that is an indication that one or more of your character variables have the CRLF characters embedded in their value.&lt;BR /&gt;There are many posts on this site on methods to pre-process the file to eliminate the embedded CRLF so that you can get a file with the right number of observations.&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Nov 2017 17:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410568#M26341</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-04T17:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410570#M26342</link>
      <description>&lt;P&gt;I'm not sure, but I don't think so, I checked the "extra" lines specifically and they all end with LF and continue in the next line. I also checked and whenever it ends with LF, the data for that line isn't over yet, it carries onto to the next line and when it reaches the end of the data, I find a CRLF.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Everything seems to be working fine with these lines. What I'm asking about, as far as I can tell, is unrelated to this since every line the vicinity of the problematic line actually ends with CRLF.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 17:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410570#M26342</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2017-11-04T17:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410572#M26343</link>
      <description>&lt;P&gt;Something else is happening.&amp;nbsp; If your file is really in UTF-16 then perhaps it is somehow corrupted and it is confusing SAS?&lt;/P&gt;
&lt;P&gt;If you look at the top of the file does it look like a UTF-16 file?&lt;/P&gt;
&lt;P&gt;For example here is a simple program to create two lines each into a "normal" and a UTF-16 file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename temp  temp ;
filename utf16 temp ;
data _null_;
  set sashelp.class (obs=2) ;
  file temp dsd termstr=crlf ;
  put (_all_) (+0);
  file utf16 dsd termstr=crlf encoding='utf-16' ;
  put (_all_) (+0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If I then look at the hex codes in those files you can see that UTF-16 files take two bytes per character.&lt;/P&gt;
&lt;PRE&gt;227  data _null_;
228    infile temp recfm=f lrecl=100 encoding='any';
229    input;
230    list;
231  run;

NOTE: The infile TEMP is:
      File Size (bytes)=42

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9

1   CHAR  Alfred,M,14,69,112.5..Alice,F,13,56.5,84.. 42
    ZONE  466766242332332333230046666242332332323300
    NUMR  1C6254CDC14C69C112E5DA1C935C6C13C56E5C84DA
NOTE: 1 record was read from the infile TEMP.
NOTE: DATA statement used (Total process time):
      real time           0.17 seconds
      cpu time            0.00 seconds


232
233  data _null_;
234    infile utf16 recfm=f lrecl=100 encoding='any';
235    input;
236    list;
237  run;

NOTE: The infile UTF16 is:
      File Size (bytes)=86

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9

1   CHAR  ÿþA.l.f.r.e.d.,.M.,.1.4.,.6.9.,.1.1.2...5.....A.l.i.c.e.,.F.,.1.3.,.5.6...5.,.8.4..... 86
    ZONE  FF406060706060204020303020303020303030203000004060606060204020303020303020302030300000
    NUMR  FE10C060205040C0D0C01040C06090C0101020E050D0A010C0903050C060C01030C05060E050C08040D0A0
NOTE: 1 record was read from the infile UTF16.
NOTE: DATA statement used (Total process time):
      real time           0.39 seconds
      cpu time            0.01 seconds

&lt;/PRE&gt;
&lt;P&gt;Perhaps something has edited the file that did not understand it was UTF-16 and has inserted invalid 2-byte sequence that is confusing SAS?&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 18:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410572#M26343</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-04T18:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410583#M26345</link>
      <description>&lt;P&gt;No idea. I'm way out of my element here, trying to convey as much useful information as I can.&lt;BR /&gt;When I import the file manually, SAS is able to do it correctly, but it seems to preprocess the file first as the file in the infile statement is a .txt and it uses the enconding WLATIN1. If I try to import using this encoding I get an error and it says that 'A byte-order mark indicates that the data is encoded in "utf-16le"'.&lt;BR /&gt;&lt;BR /&gt;How would I go about finding that 2-byte character that might be in the file? I can't find anything out of the ordinary when I open the file in Notepad++, nor on Notepad for that matter.&lt;BR /&gt;&lt;BR /&gt;Plus, when I import the file in pandas (with the encoding UTF-16), it imports it fine as well.&lt;BR /&gt;&lt;BR /&gt;I'm at a loss.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 19:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410583#M26345</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2017-11-04T19:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410593#M26347</link>
      <description>&lt;P&gt;My apologies, I muddied the waters in my earlier post, because I looked at the listing that had spaces removed, and therefore the columns didn't line up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have any explanations of the problem; in hopes of contributing, here are what I see as the pertinent details:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. There appears to be a CRLF in the middle of a line around line 10524, which SAS isn't picking up correctly. Other than that, the data on the dump on the ERROR diagnostic looks fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. On the NOTE SAS is saying it is line 10524, but _N_ is 10523. I'm guessing that's because of the Firstobs=2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. The "A character that could not be transcoded..." WARNING message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. SAS and Notepad++ are seeing 16813 records, but you feel there should be 16810 (number of CRLF plus 1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My next step would be to run the following (untested)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data _null_;&lt;BR /&gt; Infile "file_path_name" LRECL=32767 ENCODING="UTF-16" TERMSTR=CRLF;&lt;BR /&gt; File "other_file_path_name" LRECL=32767 ENCODING="UTF-16" TERMSTR=CRLF;&lt;BR /&gt; Input;&lt;BR /&gt; If _n_ = 1 | _n_ = 10524 then output;&lt;BR /&gt;Run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then try running your import program against the reduced file. If it still fails, EXTREMELY weird. If it works, evidence that something higher up is a problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then futz around with this process, maybe changing the ENCODING options, etc, until something pokes you in the eye. My feeling is it's some corrupted characters in there somewhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck,&lt;BR /&gt; Tom&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 21:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410593#M26347</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-11-04T21:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410597#M26348</link>
      <description>Thanks, I will only be able to try this in about 40 hours.&lt;BR /&gt;Actually I expect 16809 records, that's because the file ends with a blank line, so there are as many CRLFs as there are datalines.&lt;BR /&gt;The character that can't be transcoded is unrelated to this, IMO.&lt;BR /&gt;I actually asked about this here: &lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-text-file-with-Unicode-U-0099/m-p/409930#M26273" target="_blank"&gt;https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-text-file-with-Unicode-U-0099/m-p/409930#M26273&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Nov 2017 22:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410597#M26348</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2017-11-04T22:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410598#M26349</link>
      <description>&lt;P&gt;This thread is getting long. Apologies for this unrelated post, but I want to thank everyone that has been trying to help: thank you very much!&lt;BR /&gt;I'm going to keep working on this issue.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 22:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410598#M26349</guid>
      <dc:creator>Autotelic</dc:creator>
      <dc:date>2017-11-04T22:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410603#M26351</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/163649"&gt;@Autotelic&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;If it's possible then attach your actual data so we can investigate what's going on.&lt;/P&gt;
&lt;P&gt;Have you already tried if your code works on a small subset of data? Using Notepad++ create a file with only a few records but make sure you keep the line where SAS throws&amp;nbsp;the Error (plus the line right before and right after).&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 22:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410603#M26351</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-11-04T22:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing line in CSV (Invalid data for *variable* in line *line column_range*)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410610#M26353</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/163649"&gt;@Autotelic&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;No idea. I'm way out of my element here, trying to convey as much useful information as I can.&lt;BR /&gt;When I import the file manually, SAS is able to do it correctly, but it seems to preprocess the file first as the file in the infile statement is a .txt and it uses the enconding WLATIN1. If I try to import using this encoding I get an error and it says that 'A byte-order mark indicates that the data is encoded in "utf-16le"'.&lt;BR /&gt;&lt;BR /&gt;How would I go about finding that 2-byte character that might be in the file? I can't find anything out of the ordinary when I open the file in Notepad++, nor on Notepad for that matter.&lt;BR /&gt;&lt;BR /&gt;Plus, when I import the file in pandas (with the encoding UTF-16), it imports it fine as well.&lt;BR /&gt;&lt;BR /&gt;I'm at a loss.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Wait, is this the same file with the transcoding issue because of the U+0099 character?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-text-file-with-Unicode-U-0099/m-p/410194#M26297&amp;nbsp;" target="_blank"&gt;https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-text-file-with-Unicode-U-0099/m-p/410194#M26297&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your SAS session is using ENCODING=WLATIN1 then SAS will definitely trancode the file into WLATIN1 before putting it into the input buffer for the INPUT statement to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to read a UTF-16 source file then make sure that your SAS session is using ENCODING=UTF-8. The ENCODING is determined when SAS starts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should be a lot easier to read Unicode data when running SAS with Unicode support.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 23:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-importing-line-in-CSV-Invalid-data-for-variable-in-line/m-p/410610#M26353</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-04T23:57:15Z</dc:date>
    </item>
  </channel>
</rss>

