BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
devtrix
Obsidian | Level 7

 

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

devtrix
Obsidian | Level 7

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.

AlanC
Barite | Level 11

Updated. Test 1.0.0.3

https://github.com/savian-net
devtrix
Obsidian | Level 7
Alen, you are the Savian. Thank you sir.
devtrix
Obsidian | Level 7

Nuget still shows 1.0.0.2

AlanC
Barite | Level 11

Fixed.

https://github.com/savian-net
devtrix
Obsidian | Level 7

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

AlanC
Barite | Level 11

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();
            }
        }
https://github.com/savian-net
devtrix
Obsidian | Level 7
Thats it thanks. Of course any nuget related issues will go to nuget. I appreciate everything you have done. I commend you for your fast & prompt response. Thank you Alan. Have a great day. Best regards.
AlanC
Barite | Level 11

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.

https://github.com/savian-net
devtrix
Obsidian | Level 7
Absolutely. I got few hundred files I will be testing. At the end of it, if there are any issues, I will put them all together.
StanleyWei
Fluorite | Level 6
Thanks for this excellent and powerful package. Very useful~~

Just a quick question that if it is possible to bind the data object to a datatable directly? I could use the property observations and cells to retrieve the data from each row respectively, but have no idea about the direct bindling with a datatable. Any advice would be highly appreciated.

Thanks again!
Stanley
AlanC
Barite | Level 11

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?

 

https://github.com/savian-net
StanleyWei
Fluorite | Level 6

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

 

 

AlanC
Barite | Level 11

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.

 

https://github.com/savian-net

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 51 replies
  • 6063 views
  • 13 likes
  • 5 in conversation