How to read SAS data set using C#.NET

Reply
New Contributor
Posts: 2

How to read SAS data set using C#.NET

Hello all

  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.

I have tried below code but it throws exception as "The table could not be found or the index file is missing"

here is my code

DataSet sasDs = new DataSet();

String sasLibrary = @"D\a.sas7bdat";

OleDbConnection sas = new OleDbConnection("Provider=sas.LocalProvider; Data Source=" + sasLibrary);

OleDbCommand sasCommand = sas.CreateCommand();

sasCommand.CommandType = CommandType.TableDirect;

sasCommand.CommandText = "Select * from sas.a";//sasDataSet; //here i got error The table could not be found or the index file is missing

OleDbDataAdapter da = new OleDbDataAdapter(sasCommand);

da.Fill(sasDs);

sas.Close();

What i do to resolve the issue ? i think my table name is wrong ? how can i get table name ?

Please help.

Thanks in advance for your kind suggestion

Thanks

Koolprasad2003

N/A
Posts: 1

Re: How to read SAS data set using C#.NET

You are using "TableDirect" to access to SAS data.

It means that the CommandText should contain only the table name.

i.e. if you have foo.sas7bdat file, your CommandText should be:


sasCommand.CommandText = "foo"


Hope it helps.


Nicola

Super User
Posts: 9,681

Re: How to read SAS data set using C#.NET

@"D\a.sas7bdat";

->

@"D:\a.sas7bdat";   ?

Ask a Question
Discussion stats
  • 2 replies
  • 2531 views
  • 1 like
  • 3 in conversation