<?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 How to read SAS data set using C#.NET in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/168660#M264051</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;&amp;nbsp; I have SAS data file, now i want to read it using C#.NET with the help of Visual studio 2010, How can i read it.&lt;/P&gt;&lt;P&gt;I have tried below code but it throws exception as "&lt;STRONG&gt;The table could not be found or the index file is missing&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;here is my code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;DataSet&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; sasDs = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;new&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;DataSet&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;String &lt;/SPAN&gt;sasLibrary = &lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Courier New;"&gt;@"D\a.sas7bdat"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;OleDbConnection&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; sas = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;new&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;OleDbConnection&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Courier New;"&gt;"Provider=sas.LocalProvider; Data Source="&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; + sasLibrary);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;OleDbCommand&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; sasCommand = sas.CreateCommand();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;sasCommand.CommandType = &lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;CommandType&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;.TableDirect;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;sasCommand.CommandText = &lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Courier New;"&gt;"Select * from sas.a"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 10pt; font-family: Courier New;"&gt;//sasDataSet; //here i got error &lt;STRONG&gt;The table could not be found or the index file is missing&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;OleDbDataAdapter&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; da = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;new&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;OleDbDataAdapter&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;(sasCommand);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;da.Fill(sasDs);&lt;/P&gt;&lt;P&gt;sas.Close();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i do to resolve the issue ? i think my table name is wrong ? how can i get table name ?&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;Thanks in advance for your kind suggestion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Koolprasad2003&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Feb 2014 06:10:00 GMT</pubDate>
    <dc:creator>koolprasad2003</dc:creator>
    <dc:date>2014-02-10T06:10:00Z</dc:date>
    <item>
      <title>How to read SAS data set using C#.NET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/168660#M264051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;&amp;nbsp; I have SAS data file, now i want to read it using C#.NET with the help of Visual studio 2010, How can i read it.&lt;/P&gt;&lt;P&gt;I have tried below code but it throws exception as "&lt;STRONG&gt;The table could not be found or the index file is missing&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;here is my code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;DataSet&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; sasDs = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;new&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;DataSet&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;String &lt;/SPAN&gt;sasLibrary = &lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Courier New;"&gt;@"D\a.sas7bdat"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;OleDbConnection&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; sas = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;new&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;OleDbConnection&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Courier New;"&gt;"Provider=sas.LocalProvider; Data Source="&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; + sasLibrary);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;OleDbCommand&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; sasCommand = sas.CreateCommand();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;sasCommand.CommandType = &lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;CommandType&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;.TableDirect;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;sasCommand.CommandText = &lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Courier New;"&gt;"Select * from sas.a"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 10pt; font-family: Courier New;"&gt;//sasDataSet; //here i got error &lt;STRONG&gt;The table could not be found or the index file is missing&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;OleDbDataAdapter&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; da = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;new&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Courier New;"&gt;OleDbDataAdapter&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;(sasCommand);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;da.Fill(sasDs);&lt;/P&gt;&lt;P&gt;sas.Close();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i do to resolve the issue ? i think my table name is wrong ? how can i get table name ?&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;Thanks in advance for your kind suggestion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Koolprasad2003&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Feb 2014 06:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/168660#M264051</guid>
      <dc:creator>koolprasad2003</dc:creator>
      <dc:date>2014-02-10T06:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to read SAS data set using C#.NET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/168661#M264052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333;"&gt;You are using "TableDirect" to access to SAS data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333;"&gt;It means that the CommandText should contain only the table name.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333;"&gt;i.e. if you have foo.sas7bdat file, your CommandText should be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&lt;SPAN style="color: #333333;"&gt;sasCommand.CommandText =&lt;/SPAN&gt; &lt;SPAN style="color: #a31515; font-size: 10pt;"&gt;"foo"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 10pt; font-family: arial,helvetica,sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 10pt; font-family: arial,helvetica,sans-serif;"&gt;Hope it helps.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 10pt; font-family: arial,helvetica,sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Courier New;"&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif;"&gt;Nicola&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 May 2014 06:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/168661#M264052</guid>
      <dc:creator>ottomano</dc:creator>
      <dc:date>2014-05-18T06:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to read SAS data set using C#.NET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/168662#M264053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: #ffffff; color: #a31515;"&gt;@"D\a.sas7bdat"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: #ffffff;"&gt;-&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: #ffffff; color: #a31515;"&gt;@"D:\a.sas7bdat"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: #ffffff;"&gt;;&amp;nbsp;&amp;nbsp; ?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 May 2014 08:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/168662#M264053</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-05-18T08:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to read SAS data set using C#.NET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/663213#M264054</link>
      <description>&lt;P&gt;I know this is an old post but I would like to explain something here,&lt;/P&gt;&lt;P&gt;right now it seems like current provider&amp;nbsp;does not support SQL for this reason&amp;nbsp;&lt;/P&gt;&lt;P&gt;the connectionString should contain the Folder where your .&lt;SPAN&gt;sas7bdat file is.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and then when creating the command you need to specify the actual table name without include the file extension.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;e.g&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;DataSet&amp;nbsp;sasDs =&amp;nbsp;new&amp;nbsp;DataSet();
String&amp;nbsp;sasLibrary =&amp;nbsp;@"D\SomeFolder\";

OleDbConnection&amp;nbsp;connection=&amp;nbsp;new&amp;nbsp;OleDbConnection("Provider=sas.LocalProvider; Data Source="&amp;nbsp;+ sasLibrary);
connection.Open();
OleDbCommand&amp;nbsp;cmd= connection.CreateCommand();
cmd.CommandType =&amp;nbsp;CommandType.TableDirect;
cmd.CommandText =&amp;nbsp;"TableName"; 

//other option is to use the cmd.ExecuteReader();
OleDbDataAdapter&amp;nbsp;da =&amp;nbsp;new&amp;nbsp;OleDbDataAdapter(cmd);
da.Fill(sasDs);

//sasDs should contain the DataTable loaded at this point.
//you can filter the results using the DataTable.Select()

connection.Close();&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 16:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/663213#M264054</guid>
      <dc:creator>robmx</dc:creator>
      <dc:date>2020-06-18T16:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to read SAS data set using C#.NET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/718279#M264055</link>
      <description>Thx very much - finally !</description>
      <pubDate>Wed, 10 Feb 2021 15:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-SAS-data-set-using-C-NET/m-p/718279#M264055</guid>
      <dc:creator>richardlalonde</dc:creator>
      <dc:date>2021-02-10T15:47:49Z</dc:date>
    </item>
  </channel>
</rss>

