<?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: How to import line feed or carriage return values from .csv file in SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/656402#M196808</link>
    <description>&lt;P&gt;Here is.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you just pick up the first 100 records ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;options compress=yes;
data temp;
infile 'c:\temp\Sample File.csv' termstr=crlf length=len firstobs=2 lrecl=32767;
input temp $varying4000. len;
if prxmatch('/^X\d+,|^\d+-\d+,/',temp) then group+1;
run;
data temp1;
 length x $ 10000;
 do until(last.group);
   set temp;
   by group;
   x=cats(x,temp);
 end;
run;
data want;
 set temp1;
 PATIENTNUMBER=scan(x,1,',','qm');
 SEQ=scan(x,2,',','qm');
 TERM=dequote(scan(x,3,',','qm'));
 TESTSPEC_LN=dequote(scan(x,4,',','qm'));
 NL=dequote(scan(x,5,',','qm'));
 z=	dequote(scan(x,6,',','qm'));
drop x temp;
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Jun 2020 13:31:41 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2020-06-10T13:31:41Z</dc:date>
    <item>
      <title>How to import line feed or carriage return values from .csv file in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/655543#M196668</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to import the attached "Sample File.csv" however I am unable to import it successfully. I noticed that there are line feed values and possible carriage return values hence unable to import the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help in import this .csv file successfully.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename test 'C:\temp\Sample File.csv' termstr=CRLF;

proc import datafile=test
out=sample
dbms=csv
replace;
getnames=yes;
guessingrows=max;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jun 2020 14:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/655543#M196668</guid>
      <dc:creator>1239</dc:creator>
      <dc:date>2020-06-09T14:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to import line feed or carriage return values from .csv file in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/655620#M196700</link>
      <description>This topic has been discussed many times, please use the search-box.</description>
      <pubDate>Tue, 09 Jun 2020 19:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/655620#M196700</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-06-09T19:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to import line feed or carriage return values from .csv file in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/655991#M196751</link>
      <description>&lt;P&gt;Please note after searching in google for the solution I have posted this query as I didn't any get solution.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 06:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/655991#M196751</guid>
      <dc:creator>1239</dc:creator>
      <dc:date>2020-06-10T06:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to import line feed or carriage return values from .csv file in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/656282#M196778</link>
      <description>&lt;P&gt;I have tried the below two different codes however still I am unable to import it successfully hence please help me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME REFFILE 'C:\temp\Sample File.csv' TERMSTR=LF;

PROC IMPORT DATAFILE=REFFILE
	DBMS=CSV
	OUT=WORK.TEST;
	GETNAMES=YES;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WORK.TEST;
    LENGTH
        PATIENTNUMBER    $ 13
        SEQ                8
        TERM             $ 5
        TESTSPEC_        $ 200
        LN               $ 1000
        NL               $ 990 ;
    FORMAT
        PATIENTNUMBER    $CHAR13.
        SEQ              BEST1.
        TERM             $CHAR5.
        TESTSPEC_        $CHAR200.
        LN               $CHAR1000.
        NL               $CHAR990. ;
    INFORMAT
        PATIENTNUMBER    $CHAR13.
        SEQ              BEST1.
        TERM             $CHAR5.
        TESTSPEC_        $CHAR200.
        LN               $CHAR1000.
        NL               $CHAR990. ;
    INFILE 'C:\temp\Sample File.csv'
  		LRECL=32767 TERMSTR=LF DLM=',' MISSOVER DSD FIRSTOBS = 2 PAD;
    INPUT
        PATIENTNUMBER    : $CHAR13.
        SEQ              : ?? BEST1.
        TERM             : $CHAR5.
        TESTSPEC_        : $CHAR200.
        LN               : $CHAR1000.
        NL               : $CHAR990. ;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jun 2020 09:11:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/656282#M196778</guid>
      <dc:creator>1239</dc:creator>
      <dc:date>2020-06-10T09:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to import line feed or carriage return values from .csv file in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/656402#M196808</link>
      <description>&lt;P&gt;Here is.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you just pick up the first 100 records ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;options compress=yes;
data temp;
infile 'c:\temp\Sample File.csv' termstr=crlf length=len firstobs=2 lrecl=32767;
input temp $varying4000. len;
if prxmatch('/^X\d+,|^\d+-\d+,/',temp) then group+1;
run;
data temp1;
 length x $ 10000;
 do until(last.group);
   set temp;
   by group;
   x=cats(x,temp);
 end;
run;
data want;
 set temp1;
 PATIENTNUMBER=scan(x,1,',','qm');
 SEQ=scan(x,2,',','qm');
 TERM=dequote(scan(x,3,',','qm'));
 TESTSPEC_LN=dequote(scan(x,4,',','qm'));
 NL=dequote(scan(x,5,',','qm'));
 z=	dequote(scan(x,6,',','qm'));
drop x temp;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jun 2020 13:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/656402#M196808</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-06-10T13:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to import line feed or carriage return values from .csv file in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/656407#M196811</link>
      <description>By the way, Maybe you want change this .&lt;BR /&gt;&lt;BR /&gt;TESTSPEC_=dequote(scan(x,4,',','qm'));&lt;BR /&gt; LN=dequote(scan(x,5,',','qm'));&lt;BR /&gt;NL=	dequote(scan(x,6,',','qm'));&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And if yours was SAS9.2 , Try add LENGTH before scan():&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt; set temp1;&lt;BR /&gt;length PATIENTNUMBER SEQ .........  $ 2000 ;&lt;BR /&gt; PATIENTNUMBER=scan(x,1,',','qm');&lt;BR /&gt; SEQ=scan(x,2,',','qm');</description>
      <pubDate>Wed, 10 Jun 2020 13:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/656407#M196811</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-06-10T13:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to import line feed or carriage return values from .csv file in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/656445#M196822</link>
      <description>&lt;P&gt;You need to first fix the file to not have embedded end of line markers in the middle of the values of fields.&amp;nbsp; You should be able to do that by just counting the number of quotes and removing any end of line markers that are inside quotes (when the number of quotes seen is odd).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dl=C:\Downloads;
filename fixed temp;
data _null_;
  infile "&amp;amp;dl/Sample File.csv" end=eof ;
  file fixed ;
  input;
  nq+countc(_infile_,'"');
  nq=mod(nq,2);
  put _infile_ @;
  if eof or not nq then put; 
  else put '|' @;
run;


data test (compress=yes);
  infile fixed dsd truncover firstobs=2;
  input PATIENTNUMBER :$20. SEQ  TERM :$20. (TESTSPEC_ LN NL) (:$2500.);
run;

proc freq ;
  tables seq term;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;The FREQ Procedure

                                Cumulative    Cumulative
SEQ    Frequency     Percent     Frequency      Percent
--------------------------------------------------------
  1          32       32.00            32        32.00
  2          20       20.00            52        52.00
  3          15       15.00            67        67.00
  4          12       12.00            79        79.00
  5           8        8.00            87        87.00
  6           5        5.00            92        92.00
  7           4        4.00            96        96.00
  8           2        2.00            98        98.00
  9           2        2.00           100       100.00


                                  Cumulative    Cumulative
TERM     Frequency     Percent     Frequency      Percent
----------------------------------------------------------
AE             59       59.00            59        59.00
OTHER          41       41.00           100       100.00&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jun 2020 15:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-line-feed-or-carriage-return-values-from-csv-file/m-p/656445#M196822</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-10T15:01:55Z</dc:date>
    </item>
  </channel>
</rss>

