NOTE: I forgot all about it. .Net full framework wont work with Standard 2.1. It has to be standard 2.0. So if you can turn this into Standard 2.0, then it can be used in .net Core & .net 4.x.
Thanks
AlanC,
Not sure if editing my response prompts you so just as back up I am writing this. The .NET 4.x supports Standard 2.0 only. So if you could kindly turn this project into Standard 2.0, it can be used in both .NET 4.x & .NET Core.
Thanks a bunch.
Updated. Test 1.0.0.3
Nuget still shows 1.0.0.2
Fixed.
Everything works except I am not getting cell Headers like Column headers such as UPID, STUDY, SITE etc. I am uploading a sample file here.
Thank you
Since it works now, please post issues on nuget as they are discovered. I will work on them as soonas I can. The more you report now, the much faster turnaround.
This works fine in current build:
private static void StandaloneCode()
{
var engine = new Savian.SaviTransport.Engine();
var options = new Savian.SaviTransport.Options()
{
XptFile = _xptFile
};
var xptLib = engine.Process(options);
foreach (var ds in xptLib.DataSets)
{
WriteLine($"Variables: ");
foreach (var v in ds.Variables)
{
WriteLine($" - {v.Name}: {v.FormatName}{v.FormatLengthInteger}.{v.FormatLengthDecimal}, ");
}
WriteLine();
}
}
It helped me get something out to nuget. All good.
When you have a chance, please test it with the various versions of transport files and see if there are any issues.
Stanley,
I haven't touched the code in a but but look at this code:
var engine = new Savian.SaviTransport.Engine(); var options = new Savian.SaviTransport.Options() { XptFile = _xptFile }; var xptLib = engine.Process(options); foreach (var ds in xptLib.DataSets) {blah, blah, blah}
That exports the data to .NET DataSets. From there, you have datatable objects. Are you asking about converting .NET datatables to SAS XPT files?
Thanks Alan for your quick response, I just want to import the XPT file and bind the data object with a datatable/datagrid view, below codes work but I am wondering whether there would be a more efficient way to bind the object directly, instead of the current for loop statement.
Dim engine = New Savian.SaviTransport.Engine()
Dim options = New Savian.SaviTransport.Options() With {
.XptFile = strFileName
}
Dim xptLib = engine.Process(options)
For Each xpt In xptLib.DataSets
For Each v In xpt.Variables
dgvMain.Columns.Add(v.Name, v.Label)
Next
Dim intRowIndex As Integer = 0
For Each r In xpt.Observations
dgvMain.Rows.Add()
For i = 0 To dgvMain.Columns.Count - 1
dgvMain.Rows(intRowIndex).Cells(i).Value = r.Cells(i).Value
Next
intRowIndex = intRowIndex + 1
Next
Next
I may be missing something but in this code:
For Each xpt In xptLib.DataSets
the xptLib.DataSets is comprised of DataTables. Hence, you should have
For Each xpt In xptLib.DataSets[0].DataTables[0];
Also, switch away from VB.NET as soon as you can. It is a dead end (latest I have read). Convert to C# which is a great language.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.