<?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: problem facing while infile the CSV file. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372381#M89039</link>
    <description>&lt;P&gt;Posting a screenshot from Excels tells us next to nothing about the contents of your text file.&lt;/P&gt;
&lt;P&gt;Either attach the csv file to your post, or copy/paste its contents into a {i} window (very important to preserve contents and formatting!).&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jul 2017 06:26:34 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-07-01T06:26:34Z</dc:date>
    <item>
      <title>problem facing while infile the CSV file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372376#M89037</link>
      <description>&lt;P&gt;Hi Guys.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to import the CSV file through infile but i am getting below mentioned alert while doing so . Please help out in solving the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FOllowing is the CSV file i need to import:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10057iE08A79BCB6D36977/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="csv file.JPG" title="csv file.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After using infile getting following error&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10058iA9FEA0B173A2C7DF/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="err.JPG" title="err.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code Tested:&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;infile "C:\documets\2.csv" dlm="" dsd firstobs=2;&lt;/P&gt;&lt;P&gt;input cc dob enroll;&lt;/P&gt;&lt;P&gt;informat dob mmddyy10. ;&lt;/P&gt;&lt;P&gt;informat enroll date9.;&lt;/P&gt;&lt;P&gt;format dob mmddyy10.;&lt;/P&gt;&lt;P&gt;format enroll date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help in rectifyin the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 05:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372376#M89037</guid>
      <dc:creator>ROHINISDAS</dc:creator>
      <dc:date>2017-07-01T05:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: problem facing while infile the CSV file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372381#M89039</link>
      <description>&lt;P&gt;Posting a screenshot from Excels tells us next to nothing about the contents of your text file.&lt;/P&gt;
&lt;P&gt;Either attach the csv file to your post, or copy/paste its contents into a {i} window (very important to preserve contents and formatting!).&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 06:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372381#M89039</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-01T06:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: problem facing while infile the CSV file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372395#M89046</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see the whole post , i have mentioned everything then and there itself which includes the csv file that i need to import, error after i use infile as well as the code that i have tried.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Rohini&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 07:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372395#M89046</guid>
      <dc:creator>ROHINISDAS</dc:creator>
      <dc:date>2017-07-01T07:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: problem facing while infile the CSV file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372402#M89048</link>
      <description>&lt;P&gt;Theres no csv file, neither as text nor as attachment. There's just a screenshot off some data in Excel. Read my post again.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 09:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372402#M89048</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-01T09:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: problem facing while infile the CSV file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372412#M89051</link>
      <description>&lt;P&gt;You said that it's a csv file, and your log shows that it is, but you didn't specify dlm=',' in your infile statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 13:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372412#M89051</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-01T13:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: problem facing while infile the CSV file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372543#M89084</link>
      <description>&lt;P&gt;From the photograph of the SAS log that you posted your source data is a CSV file, that is a delited file of text with commas as the delimiter used between the values. &amp;nbsp;But your SAS program is using something else as the delimiter. So your program is reading the full line as the value to use for the first variable. &amp;nbsp;And since you did not include the TRUNCOVER option on your INFILE statement it tried to read the first line in CC , the second line into DOB and the third line into ENROLL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a corrected program that should work given the one line of data that you showed in the photograph of your log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  infile "C:\documets\2.csv" dlm=',' dsd firstobs=2 truncover;
  length cc dob enroll 8 ;
  informat dob mmddyy10. enroll date9.;
  format dob enroll yymmdd10. ;
  input cc dob enroll;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Jul 2017 14:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372543#M89084</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-02T14:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: problem facing while infile the CSV file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372556#M89097</link>
      <description>Thank you so much tom.&lt;BR /&gt;U solved my problem.</description>
      <pubDate>Sun, 02 Jul 2017 14:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372556#M89097</guid>
      <dc:creator>ROHINISDAS</dc:creator>
      <dc:date>2017-07-02T14:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: problem facing while infile the CSV file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372583#M89104</link>
      <description>&lt;P&gt;Hi, you can cut down on the amount of SAS code ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#1 the DSD option implies a comma delimiter so the DLM option is not needed&lt;/P&gt;
&lt;P&gt;#2 your dates are in standard forms so the ANYDTDTE informat works for both&lt;/P&gt;
&lt;P&gt;#3 the default length of numeric variables is 8, so the LENGTH statement is not needed&lt;/P&gt;
&lt;P&gt;#4 it's just LIST input, so you can add the INFORMAT in the INPUT statement and leave out the INFORMAT statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;data a;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;infile "z:\test.csv" dsd firstobs=2;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;format dob enroll yymmdd10. ;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;input cc (dob enroll) (:anydtdte.);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 16:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372583#M89104</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2017-07-02T16:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: problem facing while infile the CSV file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372606#M89117</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13759"&gt;@MikeZdeb&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi, you can cut down on the amount of SAS code ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#1 the DSD option implies a comma delimiter so the DLM option is not needed&lt;/P&gt;
&lt;P&gt;#2 your dates are in standard forms so the ANYDTDTE informat works for both&lt;/P&gt;
&lt;P&gt;#3 the default length of numeric variables is 8, so the LENGTH statement is not needed&lt;/P&gt;
&lt;P&gt;#4 it's just LIST input, so you can add the INFORMAT in the INPUT statement and leave out the INFORMAT statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Mike -&lt;/P&gt;
&lt;P&gt;#1 - I purposely included the DLM= option because the original poster had used this option wrong and I wanted to highlight what delimiter they should be using.&lt;/P&gt;
&lt;P&gt;#2 - I puposely used the informats that the user used since they matched the formats in the sample line of data. Note that the ANYDTDTE can make the wrong decision about whether ambigous values should be treated as M/D/Y or D/M/Y.&lt;/P&gt;
&lt;P&gt;#3 - The LENGTH statement is not optional in my opinion. Without it you have to rely on SAS making the decision on both the position of the variable is the data set and also the variables type and length based on how they first appear in the code. &amp;nbsp;Not a good way to define your data.&lt;/P&gt;
&lt;P&gt;#4 - You could add the informats in the INPUT statement, but then you need to remember to use the : modifier or else you risk that the formatted input will "eat" delimiters and cause the values to be read into the wrong variables. &amp;nbsp;Also it preludes using a variable list in the INPUT statement. &amp;nbsp;Normally for a CSV file the INPUT statement is simply "&lt;STRONG&gt;input firstvar -- lastvar;&lt;/STRONG&gt;" .&lt;/P&gt;
&lt;P&gt;#5 - You remove the TRUNCOVER option from the INFILE statement, another mistake that caused the original program to not work.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 18:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-facing-while-infile-the-CSV-file/m-p/372606#M89117</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-02T18:48:00Z</dc:date>
    </item>
  </channel>
</rss>

