<?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: Importing a csv file in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Importing-a-csv-file/m-p/4555#M1845</link>
    <description>If you are using a wizard in Enterprise Guide or something else, it will be a tedious chore for you. I usually read CSV files with custom-written SAS code that validates all values.&lt;BR /&gt;
&lt;BR /&gt;
I read in all numeric and date values as character with names such as START_DATE_CHAR, ACCOUNT_NUMBER_CHAR, and so on. Then I check each one like this:&lt;BR /&gt;
&lt;BR /&gt;
   infile&lt;BR /&gt;
      "account_info.csv" dsd firstobs=1 lrecl=400 missover print; &lt;BR /&gt;
          &lt;BR /&gt;
   input&lt;BR /&gt;
      account_number_char     $10.&lt;BR /&gt;
      start_date_char   $15.;&lt;BR /&gt;
&lt;BR /&gt;
   if compress(start_date_char) ne '' then&lt;BR /&gt;
      start_date = input(start_date_char, ddmmyy10.);&lt;BR /&gt;
   else&lt;BR /&gt;
      start_date = .;&lt;BR /&gt;
&lt;BR /&gt;
   if compress(account_number_char) not in ('-', '?', '') then&lt;BR /&gt;
      account_number = input(account_number_char, 8.);&lt;BR /&gt;
   else&lt;BR /&gt;
      account_number = 0;&lt;BR /&gt;
&lt;BR /&gt;
Then DROP the _CHAR variables. In this manner, you can trap any data exception from Excel and handle it exactly the way you want. You can also check field lengths. But you'll need to write SAS code.

Message was edited by: Roddy</description>
    <pubDate>Wed, 12 Sep 2007 08:54:28 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2007-09-12T08:54:28Z</dc:date>
    <item>
      <title>Importing a csv file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Importing-a-csv-file/m-p/4553#M1843</link>
      <description>Is there a way that I can have SAS check each variable to determine if it should be character, or numeric and the appropraite length? I currently use the import wizard then copy from the log and modify it as needed, but with many files to read in, this get very time consuming.&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Wed, 05 Sep 2007 16:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Importing-a-csv-file/m-p/4553#M1843</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-09-05T16:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a csv file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Importing-a-csv-file/m-p/4554#M1844</link>
      <description>Hi,&lt;BR /&gt;
  There is a GUESSINGROWS option, but I can't remember whether it is for the LIBNAME engine or PROC IMPORT. You could check with the doc or with Tech Support.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 05 Sep 2007 16:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Importing-a-csv-file/m-p/4554#M1844</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-09-05T16:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a csv file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Importing-a-csv-file/m-p/4555#M1845</link>
      <description>If you are using a wizard in Enterprise Guide or something else, it will be a tedious chore for you. I usually read CSV files with custom-written SAS code that validates all values.&lt;BR /&gt;
&lt;BR /&gt;
I read in all numeric and date values as character with names such as START_DATE_CHAR, ACCOUNT_NUMBER_CHAR, and so on. Then I check each one like this:&lt;BR /&gt;
&lt;BR /&gt;
   infile&lt;BR /&gt;
      "account_info.csv" dsd firstobs=1 lrecl=400 missover print; &lt;BR /&gt;
          &lt;BR /&gt;
   input&lt;BR /&gt;
      account_number_char     $10.&lt;BR /&gt;
      start_date_char   $15.;&lt;BR /&gt;
&lt;BR /&gt;
   if compress(start_date_char) ne '' then&lt;BR /&gt;
      start_date = input(start_date_char, ddmmyy10.);&lt;BR /&gt;
   else&lt;BR /&gt;
      start_date = .;&lt;BR /&gt;
&lt;BR /&gt;
   if compress(account_number_char) not in ('-', '?', '') then&lt;BR /&gt;
      account_number = input(account_number_char, 8.);&lt;BR /&gt;
   else&lt;BR /&gt;
      account_number = 0;&lt;BR /&gt;
&lt;BR /&gt;
Then DROP the _CHAR variables. In this manner, you can trap any data exception from Excel and handle it exactly the way you want. You can also check field lengths. But you'll need to write SAS code.

Message was edited by: Roddy</description>
      <pubDate>Wed, 12 Sep 2007 08:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Importing-a-csv-file/m-p/4555#M1845</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-09-12T08:54:28Z</dc:date>
    </item>
  </channel>
</rss>

