0

I have a C# application that reads data from a MS SQL Server database. What I need to do is to create a class that

  • recovers data from certain views on the database
  • writes the data to files which are in a SAS-readable format

In other words : I need to produce a .SAS7BDAT file from a DataTable inside C# which contains data from a SQL Server database.

Can anyone help? Thanks

Giuseppe
  • 625
  • 1
  • 9
  • 15
  • Nope, not clear. I'm not sure what `recovers data from views` means, nor do I know what a `SAS-readable format` is. – crthompson Jul 09 '14 at 14:10
  • Recovers data from view : has a DataTable object in memory with all the data. One that could be easily used to write the data to a .csv file, for instance. SAS readable format: a data file that can be imported directly into SAS without any intermediate conversion step. – Giuseppe Jul 09 '14 at 14:12
  • There are plenty of examples of [writing a csv from a datatable](http://stackoverflow.com/a/14971077/2589202). How does yours differ? – crthompson Jul 09 '14 at 14:18
  • In that I have to write a file directly readable from SAS, not a csv. – Giuseppe Jul 09 '14 at 14:19
  • Perhaps there are those on SO who immediately know what the specs for a SAS readable format are. But for those that dont, you could enlighten us. – crthompson Jul 09 '14 at 14:20
  • 1
    The question is intended for people who know SAS, of course. Otherwise, I would have not asked it. I need to produce a .SAS7BDAT file from a DataTable inside C# which contains data from a SQL Server database. That's it. – Giuseppe Jul 09 '14 at 14:45
  • 2
    Do you have access to a SAS installation or server of any sort? SAS is a closed format, and while SAS provides an OLEDB driver for reading SAS files, it doesn't provide a free way to write them. – Joe Jul 09 '14 at 14:46
  • @Giuseppe, that is much more clear, perhaps you could edit your question to reflect that. – crthompson Jul 09 '14 at 14:47
  • I do not have a SAS installation but should provide the output files to someone who does. – Giuseppe Jul 09 '14 at 14:49
  • 2
    The importance of the SAS installation is in the writing. You normally would need a SAS installation (either a local copy of base, or a server) to write a SAS7BDAT. – Joe Jul 09 '14 at 14:55

1 Answers1

1

This isn't possible without SAS, or a custom library not freely available.

SAS provides OLEDB drivers for this purpose, but they require a SAS installation (of various sorts), as referred to in this table. You can read SAS7BDAT with the free local provider, but not write.

CozyROC sells a SAS compatible .NET library that allows you to write to SAS directly. That's the only way I'm aware you could do this. Alan Churchill has done this also on his own (decoded the SAS7BDAT format), but I suspect he sold his work to CozyROC since he now links to them.

Joe
  • 62,789
  • 6
  • 49
  • 67