<?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: Observed error while reading unstructured data (CSV) into Library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736776#M229600</link>
    <description>&lt;P&gt;PROC IMPORT has a lot of quirks.&amp;nbsp; Apparently one of them is that it cannot be used to write directly to a library defined with the XLSX engine.&lt;/P&gt;
&lt;P&gt;So either create a work dataset and copy that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname xl1 xlsx "~/EPG1V2/data/class.xlsx";

proc import datafile="~/EPG1V2/data/class_birthdate.csv" dbms=csv out=class_birthdate1 replace;
run;
data xl1.class_birthdate1;
  set class_birthdate1 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just skip the PROC IMPORT and read the text file directly with your own data step.&amp;nbsp; If you do that you also eliminate all of the other quirky behavior of PROC IMPORT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data xl1.class_birthdate1;
  infile "~/EPG1V2/data/class_birthdate.csv" dsd truncover firstobs=2;
  input .... ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 24 Apr 2021 20:58:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-04-24T20:58:45Z</dc:date>
    <item>
      <title>Observed error while reading unstructured data (CSV) into Library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736743#M229580</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I am using SAS Studio and trying to read unstructured data (CSV) into library.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following are examples, where in example 1 run without errors, while in example 2 error observed is "&lt;SPAN&gt; Import cancelled. The dataset XL1.CLASS_BIRTHDATE1 is being used and cannot be replaced".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can anyone help to understand the error, and for successful run of example 2.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;EXAMPLE 1 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;(created library DATA1 and read SAS data tables from data folder. followed by using proc import to read CSV file in DATA1 library. Run was successful)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname DATA1 "~/EPG1V2/data";&lt;/P&gt;&lt;P&gt;proc import datafile="~/EPG1V2/data/class_birthdate.csv" dbms=csv out=data1.class_birthdate1 REPLACE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;EXMAPLE 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(created library xl1 and read xl workbook class from data folder. followed by using proc import to read CSV file in xl1 library. observed error)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname xl1 xlsx "~/EPG1V2/data/class.xlsx";&lt;/P&gt;&lt;P&gt;proc import datafile="~/EPG1V2/data/class_birthdate.csv" dbms=csv out=xl1.class_birthdate1 replace;&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;Thanks!!&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 13:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736743#M229580</guid>
      <dc:creator>evach</dc:creator>
      <dc:date>2021-04-24T13:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: Observed error while reading unstructured data (CSV) into Library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736747#M229581</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Showing your log would learn us a lot more. (Next time, publish the log!).&lt;/P&gt;
&lt;P&gt;But OK.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;gt; "Import cancelled. The dataset XL1.CLASS_BIRTHDATE1 is being used and cannot be replaced".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I guess you are viewing an earlier version of&amp;nbsp;XL1.CLASS_BIRTHDATE1 with a VT (ViewTable) or FSV (Full-Screen View) command. Is that possible? At least the table is in use "somewhere and somehow".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Solution: Close the table view or table usage and run your code again.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Koen&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 14:03:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736747#M229581</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-04-24T14:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Observed error while reading unstructured data (CSV) into Library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736749#M229582</link>
      <description>&lt;P&gt;Oh, wait.&lt;/P&gt;
&lt;P&gt;I see your libname statement now!&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp;&lt;SPAN&gt;libname xl1 xlsx "~/EPG1V2/data/class.xlsx";&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Are you trying to create an Excel file (.xlsx) from a .csv file? You are not pointing to a folder but to a file.&lt;/P&gt;
&lt;P&gt;You should do that in Excel (converting a .csv into a .xlsx).&lt;/P&gt;
&lt;P&gt;And to export SAS tables to Excel you need a PROC EXPORT ((SAS/ACCESS Interface to PC Files External File Interface (EFI)).&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 14:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736749#M229582</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-04-24T14:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Observed error while reading unstructured data (CSV) into Library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736750#M229583</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;I'm confused by what you're trying to do. In Example 1, you are IMPORTING (reading in) a CSV file and creating a SAS data set, data.class_birthdate1. In Example 2, you are IMPORTING (reading in) a CSV file and trying to create an XLSX workbook called CLASS.XLSX in the data subfolder. &lt;BR /&gt;&lt;BR /&gt;The OUT= option for PROC IMPORT must specify a SAS dataset. You are trying to specify an Excel Workbook using the XLSX engine. When we make the data for the Programming 1 class, we give you an XLSX file called CLASS.XLSX. So it looks from your program as if you are trying to replace the original CLASS.XLSX file with the data in a CSV file by importing CLASS_BIRTHDATE.CSV. &lt;BR /&gt;&lt;BR /&gt;The challenge with Example 2 is that for PROC IMPORT your OUT= must be a 1 level or 2 level SAS dataset name. My guess is that is why you are getting an import cancelled message. &lt;BR /&gt;&lt;BR /&gt;Where are you working in the course? What Lesson, Activity or Practice are you doing? I do not recall a practice that tells you to import CLASS_BIRTHDATE.CSV and use the XLSX engine for the dataset created from PROC IMPORT. Your Example 1 is correct because you are reading in or importing a CSV file and writing out a SAS dataset using the regular Base LIBNAME engine to create a proprietary SAS data set table. Your Example 2 is confusing to me about what you're trying to import and why your output is not a SAS dataset.To import this CSV file, I would expect you to create a SAS dataset as output. like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1619276347219.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58652iCA38F5ADE0B8850B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1619276347219.png" alt="Cynthia_sas_0-1619276347219.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; We cover exporting to Excel in Lesson 6 in the class.&lt;BR /&gt;&lt;BR /&gt;Cynthia&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 14:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736750#M229583</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-04-24T14:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Observed error while reading unstructured data (CSV) into Library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736776#M229600</link>
      <description>&lt;P&gt;PROC IMPORT has a lot of quirks.&amp;nbsp; Apparently one of them is that it cannot be used to write directly to a library defined with the XLSX engine.&lt;/P&gt;
&lt;P&gt;So either create a work dataset and copy that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname xl1 xlsx "~/EPG1V2/data/class.xlsx";

proc import datafile="~/EPG1V2/data/class_birthdate.csv" dbms=csv out=class_birthdate1 replace;
run;
data xl1.class_birthdate1;
  set class_birthdate1 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just skip the PROC IMPORT and read the text file directly with your own data step.&amp;nbsp; If you do that you also eliminate all of the other quirky behavior of PROC IMPORT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data xl1.class_birthdate1;
  infile "~/EPG1V2/data/class_birthdate.csv" dsd truncover firstobs=2;
  input .... ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 24 Apr 2021 20:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observed-error-while-reading-unstructured-data-CSV-into-Library/m-p/736776#M229600</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-24T20:58:45Z</dc:date>
    </item>
  </channel>
</rss>

