<?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: Import CSV files -one or more lines truncated in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/741950#M19956</link>
    <description>Do not use DBMS=CSV, as that would indicate commas as delimiters. Use DBMS=DLM, with '09'x as delimiter.</description>
    <pubDate>Mon, 17 May 2021 18:21:37 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-05-17T18:21:37Z</dc:date>
    <item>
      <title>Import CSV files -one or more lines truncated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/741939#M19955</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to import a csv file into SAS. The delimiter is a tap. The log window showed one or more lines were truncated. Then, I have added&amp;nbsp;guessingrows=max in my code. The&amp;nbsp;log window shows the data set was successfully created, but it was not.&amp;nbsp; The data set has 105 variables. The log window shows it has only 13 variables. Any advice and suggestions would be highly appreciated.&amp;nbsp;&amp;nbsp;Here is my code and log window message.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC IMPORT OUT=DICAID_20_1 DATAFILE="D:\Mala\E-UL-Data&lt;BR /&gt;&amp;nbsp;Request_2000.csv"&lt;BR /&gt;DBMS=CSV REPLACE;&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;RUN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;328&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;329&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _ERROR_ then call symputx('_EFIERR_',1);&amp;nbsp; /* set ERROR detection macro variable */&lt;/P&gt;&lt;P&gt;330&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: The infile 'D:\Mala\E-UL-Data Request_2013.csv' is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Filename=D:\Mala\E-UL-Data Request_2013.csv,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RECFM=V,LRECL=32767,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; File Size (bytes)=4975718400,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Last Modified=29Apr2021:12:06:18,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create Time=29Apr2021:12:35:46&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: 5522752 records were read from the infile 'D:\Mala\E-UL-Data Request_2013.csv'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The minimum record length was 330.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The maximum record length was 1634.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.DICAID_20_1 has 5522752 observations and 13 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 53:32.57&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 34.87 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output:&lt;/P&gt;&lt;P&gt;CHAR CLAIM_GUID.NUM_DTL.DTE_PTN.DTE_FIRST_SVC.DTE_LAST_SVC.DTE_ADMISSION.DTE_DISCHARGE.BEN_&lt;BR /&gt;ZONE 44444545440454545404545554045454455555540454544555554045454444554440454544544454404445&lt;BR /&gt;NUMR 3C19DF75949E5DF44C9445F04E9445F69234F3639445FC134F3639445F14D9339FE9445F493381275925EF&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 18:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/741939#M19955</guid>
      <dc:creator>bxg95</dc:creator>
      <dc:date>2021-05-17T18:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV files -one or more lines truncated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/741950#M19956</link>
      <description>Do not use DBMS=CSV, as that would indicate commas as delimiters. Use DBMS=DLM, with '09'x as delimiter.</description>
      <pubDate>Mon, 17 May 2021 18:21:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/741950#M19956</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-17T18:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV files -one or more lines truncated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/741955#M19957</link>
      <description>&lt;P&gt;You told PROC IMPORT to use comma as the delimiter.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But from your example:&lt;/P&gt;
&lt;PRE&gt;CHAR CLAIM_GUID.NUM_DTL.DTE_PTN.DTE_FIRST_SVC.DTE_LAST_SVC.DTE_ADMISSION.DTE_DISCHARGE.BEN_
ZONE 44444545440454545404545554045454455555540454544555554045454444554440454544544454404445
NUMR 3C19DF75949E5DF44C9445F04E9445F69234F3639445FC134F3639445F14D9339FE9445F493381275925EF&lt;/PRE&gt;
&lt;P&gt;It looks instead you have '09'x as the delimiter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So tell PROC IMPORT that by adding this statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;delimiter='09'x;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 May 2021 18:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/741955#M19957</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-17T18:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV files -one or more lines truncated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742159#M19962</link>
      <description>Thank you, KurtBremser. As you suggested, I have edited my code and run it. The program is still running since yesterday at noon and the log window is completely blank. I am running through the VPN. Do you know why it takes this much time?</description>
      <pubDate>Tue, 18 May 2021 13:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742159#M19962</guid>
      <dc:creator>bxg95</dc:creator>
      <dc:date>2021-05-18T13:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV files -one or more lines truncated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742161#M19963</link>
      <description>Thank you, Tom. As you suggested, I have edited my code and run it. The program is still running since yesterday at noon and the log window is completely blank. I am running through the VPN. Do you know why it takes this much time?</description>
      <pubDate>Tue, 18 May 2021 13:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742161#M19963</guid>
      <dc:creator>bxg95</dc:creator>
      <dc:date>2021-05-18T13:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV files -one or more lines truncated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742164#M19964</link>
      <description>&lt;P&gt;The file is fairly large (5,522,752 observations ) plus now that you have the right delimiter it will probably detect many more columns (aka variables).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But that does seem like a long time.&amp;nbsp; Are you sure that you did not forget the RUN statement? Or have unbalanced quotes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know what variables you expect to have in the file?&lt;/P&gt;
&lt;P&gt;It it will run much faster if you just write your own data step to read the file instead of forcing SAS to guess how to define the variables.&amp;nbsp; Plus you will have more control over how the variables are defined.&amp;nbsp; You can definitely do a much better job at guessing how to define the variables than PROC IMPORT can.&amp;nbsp; It does not have any domain knowledge of what this data is supposed to represent.&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 14:08:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742164#M19964</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-18T14:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV files -one or more lines truncated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742182#M19969</link>
      <description>&lt;P&gt;As stated by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, you are much better off writing the data step yourself. It will take some time to write it, but it gives you full control over the process, and avoids the analyzation step that IMPORT has to do.&lt;/P&gt;
&lt;P&gt;I simply copy/paste the first line of the data file and use it to write the INPUT statement. My knowledge of the column metadata taken from the documentation (you DID receive documentation, didn't you?) helps me define the correct variable attributes.&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 14:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742182#M19969</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-18T14:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV files -one or more lines truncated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742201#M19970</link>
      <description>Yes, the data set has more than 6M.&lt;BR /&gt;Yes, I know the variables in the dataset. There are 105 variables. I am sorry, what do you mean by write own data step? Do you mean using INFILE statement?</description>
      <pubDate>Tue, 18 May 2021 15:12:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742201#M19970</guid>
      <dc:creator>bxg95</dc:creator>
      <dc:date>2021-05-18T15:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV files -one or more lines truncated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742208#M19971</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/382339"&gt;@bxg95&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Yes, the data set has more than 6M.&lt;BR /&gt;Yes, I know the variables in the dataset. There are 105 variables. I am sorry, what do you mean by write own data step? Do you mean using INFILE statement?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes. Using a data step to read a structured text file is basic SAS technique, any starting SAS programmer needs to learn that.&lt;/P&gt;
&lt;P&gt;For the past 20+ years, this has been the bread and butter of my daily work (reading unload files delivered from the databases).&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 15:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742208#M19971</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-18T15:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV files -one or more lines truncated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742278#M19972</link>
      <description>&lt;P&gt;Yes. And DATA statement and other statements to form a full data step.&lt;/P&gt;
&lt;P&gt;Something like this.&amp;nbsp; Fill in the definition of all 108 variables in the LENGTH statement. Numeric variables should have length of 8 since SAS stores all numbers as 64-bit floating point numbers.&amp;nbsp; Attach and REQUIRED informats or FORMATS.&amp;nbsp; If you define the variables in the order they appear in the text file then the input can use a positional variable list so you don't have to retype all 108 variable names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DICAID_20_1;
  infile "D:\Mala\E-UL-Data Request_2000.csv" dsd dlm='09'x truncover firstobs=2;
  length var1 8 var2 $20 var3 8 var5 $5 .... var108 8 ;
  informat var27 yymmdd.;
  format var27 yymmdd10.;
  input var1 -- var108;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you don't have a handy source for the variable names just copy the first line of the text file and paste it into your LENGTH statement and add the lengths for each variable.&amp;nbsp; Here is a simple data step to copy them and paste them into the log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "D:\Mala\E-UL-Data Request_2000.csv" dsd dlm='09'x obs=1 ;
  input name :$32. @@;
  put name;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note for most variables SAS does NOT need to have special instructions for&amp;nbsp; either reading from text into values (informat) or writing values into text (format).&amp;nbsp; Especially for CHARACTER variables. Most often you only need to set the informat or format for DATE, TIME or DATETIME values.&amp;nbsp; If there are numbers with commas in them you will need to use the COMMA informat.&amp;nbsp; If you want the numbers displayed with a fixed number of decimal places attach the w.d format to those variables. There is no need for a special informat to read those numbers however.&amp;nbsp; But if the numbers in the text file use an implied decimal place to save space (12 dollars and 34 cents is stored as "1234" instead of "12.34") then use an informat with a decimal specification of the number of decimal places to imply.&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 20:57:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-files-one-or-more-lines-truncated/m-p/742278#M19972</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-18T20:57:13Z</dc:date>
    </item>
  </channel>
</rss>

