Desktop productivity for business analysts and programmers

how to create a sas7bdat file from C#

Not applicable
Posts: 1

how to create a sas7bdat file from C#


I apologize if this is not the correct discussion group for this question; it seemed like the best choice.

I have an application written in C# that has a requirement to create sas data files, specifically the sas7bdat format.  I'm trying to figure out what SAS integration options are available for doing so.


  1. We do not own any SAS products but are not averse to buying them in order to satisfy our needs to produce sas7bdat files.
  2. If it is helpful, the data to be converted can be written to an intermediate format (e.g. a CSV file) prior to the conversion to the sas7bdat format.
  3. We'd prefer not to have generate/write SAS code to create the sas7bdat file.  In other words, ideally, through the purchase of some SAS product, we gain access to a C# DLL that is capable of taking some in-memory data structure or a reference to a data file (e.g. CSV) and creating a sas7bdat file.
  4. We currently have a working integration with StatTransfer but we are evaluating other options.

Thank you for your time.  If our needs are unclear, please ask us to clarify.

Community Manager
Posts: 3,462

Re: how to create a sas7bdat file from C#

Posted in reply to fs_sas_newbie

See some references here:

Peek at your data using VBScript, OLE DB, and the SAS local data provider - The SAS Dummy

Using Windows PowerShell to view your SAS data dictionary

These both use the SAS OLE DB data providers, which are available from  However, their primary purpose is for reading and perhaps updates, not as much for creating new SAS7BDAT files.


Posts: 1,334

Re: how to create a sas7bdat file from C#

Posted in reply to fs_sas_newbie

I'm not a C# guy, but one of my friends at Statistics Canada is!

Hope this helps you out.


Super User
Super User
Posts: 8,279

Re: how to create a sas7bdat file from C#

Posted in reply to fs_sas_newbie

What is the aversion to writing SAS code, or really writing a SAS code generating module in your C program?

Code to create a SAS dataset from a CSV file is trivial to write, especially if you limit the types of inputs that you need to support.

Trusted Advisor
Posts: 3,215

Re: how to create a sas7bdat file from C#

Posted in reply to fs_sas_newbie

The question is unclear in its goal.

If you want just to deliver a file that easily can be read by users running SAS.....

- The csv file approach could be sufficient. But do not use comma as delimeters  with a european relation using the decimal separators different.

- the transport-file could be sufficient although it is based on SAS-V6 .


  This is the only public available description of a typical SAS data-structure. The internal sas7bdat structure is only open to dedicated partners like syncsort

  This is pushing some pressure on release management of the SAS middleware (SAS system) as the structure of a sas7bdat is changing with SAS releases.

By the way,

-  you could involve your C# code from a running SAS-session   

   40562 - Defining a C function and calling it from the SAS® System

SAS has stopped with their C-offering, but you can still find a lot

  Introduction to the SAS/C C++ Development System : Overview of the SAS/C C++ Development System

The SAS/toolkit software is still mentioned. but I have not seen any updates since SAS v6   

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 4 replies
  • 5 in conversation