- Download and install the SAS Universal Viewer from the SAS support site
- Create a new project in Visual Studio
- Add a reference from the SAS Universal Viewer install files to the following 2 dlls
- SAS.UV.Transport
- SAS.UV.Utility
- Use the following C# code (adapt as needed):
TransportFile tf = new TransportFile(@"x:\temp\sample.xpt"); var x = tf.Datasets;
Your dataset will be in variable x
UPDATED: 11/8/2017
[NOTE: I have also created a direct reader for the XPT binary format. That took a long time (a week, maybe). Contact me if you need that]
Complete code:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SAS.UV.Transport;
namespace ReadSasXportFiles
{
class Program
{
static void Main(string[] args)
{
var tf = new TransportFile(@"x:\temp\shoes.xpt");
var x = tf.Datasets;
}
}
}
IMPORTANT NOTE: Make sure your build is set for x64 and not Any CPU. You will see a warning:
Warning There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "SAS.UV.Transport", "AMD64".
No comments:
Post a Comment