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

Happy New Year AlanC!

 

Thanks for your suggestion to switch C# and I will take it seriously. 😀. As for the datatable property, I tried to use that but seems not available in VB.NET, only tolist or to array could be accessable within datasets, is DataTable specifically designed for C# only?

 

Regards,

Stanley

AlanC
Barite | Level 11

You need to translate my C# to VB.NET: I can't easily do that. Look at a tool like this one: Code Converter C# to VB and VB to C# – Telerik

 

Here is the what I believe is the correct code for VB.NET:

 

For Each xpt In xptLib.DataSets(0).Tables(0);

 

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

Yes, I did convert it to VB format but says datatable or table is not a member of datasets.

AlanC
Barite | Level 11

And this is VB.NET, not VB? Can you show code?

https://github.com/savian-net
AlanC
Barite | Level 11
Also, datatable is not part of datasets. It is part of dataset. Make sure you qualify with an array value: datasets(0).
https://github.com/savian-net
StanleyWei
Fluorite | Level 6

Yes, used in VB.NET. Below is the code, I tried to use Tables, DataTables, Tables(0), DataTables(0) but neither works, saying Tables.DataTables not the member of DataSets. I just would like to think about a more efficient way to import the data and bind with a datagridview, the codes in the second part works but might not be the best way. Please advise. Thanks a lot~~

StanleyWei_1-1609511642165.png

Regards,

Stanley

AlanC
Barite | Level 11

Stanley,

 

The issue was on my side. I saw the word 'DataSets' and assumed it was .NET: it wasn't. Just a **** move on my part. I have updated the Git repository with a new build. Highlights:

 

  • New ToDataSet method

  • Fixed issue with extra record on Observations
  • Renamed DataSets to XportDataSets

Let me know of any issues. Thanks for your patience and testing.

 

PS - When you post to these coding forums, never use an image. In this case I didn't need the code but normally someone has to highlight the code and copy and an image does not work.

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

That's great, just test it and works well, except one minor issue when imported cell with null value, I just added the if statement  as follows and works well now.

 

 foreach (var obs in xds.Observations)
{
var dr = dt.Rows.Add();
foreach (var c in obs.Cells)
{
if (!(c.Value is null))
{
dr[c.Column] = c.Value;
}
}

 

Cheers,

Stanley

StanleyWei
Fluorite | Level 6

Another issue just found was that the returned table name was always 9.4, not the real file name.

AlanC
Barite | Level 11

Thanks Stanley. Fixed both issues and pushed to repo.

 

Also, changed your if to the following (is not null is a new feature in C#9. Resharper will bark but is legit):

 

                       if (c.Value is not null)
                        {
                            dr[c.Column] = c.Value;
                        }

 

https://github.com/savian-net
AlanC
Barite | Level 11

I did a complete overhaul on the way that the library works for exporting content. Minor impact on the initialization (but breaking change). I wrote this code years ago so it was pretty different mindset and built as a console app. Changed it up to reflect a library. See readme on the repo for sample code. 

https://github.com/savian-net
nivasoft
Calcite | Level 5

Hi Alan,

 

Trying to use your SaviTransport package. I am not getting any Datasets back (it is zero). I doubt if the transport file I got is a compressed version. Any help and guidance from you is much appreciated.

 

Thanks

Nivasoft

AlanC
Barite | Level 11

What version of XP file is it? Is the extension xpt? Any chance you can share it in private? If so, send me an email directly with your email address and i will provide a private folder for you to use.

https://github.com/savian-net
nivasoft
Calcite | Level 5
Hi Alan,

Hope this email reaches you. It is this file enclosed here. They do not
have XPT extensions.

The instructions to use them in SAS is as below. I would like to use your
library and pull them in.

Code for converting coefficients transport file to SAS file:

*filename* inc "*C:\user defined location of the transport file*\C2214O5P";

*libname* incoef "*C:\user defined location of the sas coefficients file*";

*proc* *cimport* *data=*incoef.hcccoefn *infile**=*inc;

*run*;

Code for converting formats transport file to SAS file:

*filename* inf "*C:\user defined location of the transport file*\F2222O1P";

*libname* library "C:\user defined location of the sas formats file";

*proc* *cimport* *library**=**library* *infile**=*inf;

*run*;

Let me know what you think.
Muthu
nivasoft
Calcite | Level 5
I replied to your email. I am not sure if reached you yet.

Thanks
Muthu

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 5013 views
  • 13 likes
  • 5 in conversation