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

Hi all,

I have been tasked with opening and reading xpt files in C#.  Using code similar to this has worked great so far:

 

            var tf = new TransportFile(@"x:\temp\shoes.xpt");
            var x = tf.Datasets;

However, when accessing the tf.Datasets[0].Data.Rows, this only ever finds the first 100 rows of data.  Does anyone know why this could be and a way to fix this?  I know for a fact there are more rows with the particular file that I am opening.  The version of SAS.UV.Transport is based on SAS Universal Viewer version 1.5.

 

Thank you in advance!

Adam

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

So can you tell from this DLL what parameters the function takes?

I would assume that it has a default of returning data in 100 observation chunks.

So perhaps there is a parameter to tell it to return more.  Or to tell to start from observations 101 so that you can read it in chunks and put it back together.

View solution in original post

8 REPLIES 8
ChrisHemedinger
Community Manager

Hi @aneemo,

 

I don't know the answer to this, but I need to point out that SAS does not support the use of SAS Universal Viewer assemblies in this way. These are undocumented internal routines not supported for customers to use in other applications.

 

If the SAS Universal Viewer supports the function properly in its UI, that's the way to go. I get that you are probably trying to automate this...but we are limited in the support we can offer. (But...does not prevent you from trying or waiting for other community answers.)

SAS Innovate 2025: Call for Content! Submit your proposals before Sept 16. Accepted presenters get amazing perks to attend the conference!
aneemo
Fluorite | Level 6

Hello Chris!

 

Thank you for the feedback, this is no problem at all!  I completely understand there would not be an support for this...just wanted to see if anyone might have seen this before or have a hint on something to try.

 

Thank you!

Adam

SASKiwi
PROC Star

This is a dumb question, but am I correct in assuming the Universal Viewer itself can display all rows in the XPT file you are testing with?

aneemo
Fluorite | Level 6

Ha, that was the first thing I checked to make sure when I saw this error and yes, the Universal Viewer does display all rows.  I also have a tool to convert this file to csv and all the rows are in the resulting csv file as well.

I also made sure to close the application to be sure the file is not accessed in any other way and that did not help either.

I did also test with another file that has >100 rows and the exact same thing happens with this other file as well.  I am testing in Visual Studio 2022 Profession Version 17.5 and .NET Framework 4.8 if that makes a difference.

SASKiwi
PROC Star

Another dumb question...I assume you are taking this path because you don't have a SAS installation that can import the XPT files the "normal" way? If you do have at least one SAS installation that can translate the files, then you could consider converting them into a form your application can work with rather than using unsupported techniques.

aneemo
Fluorite | Level 6

Hello, thank you for the reply...I guess I am being stubborn with this.  Your suggestion is certainly a way that we could go, it's just the group is used to working with xpt files and that's what I was told to use for this project.  I will check with them to see if converting them to another format would be an option if I can't get this to work soon.

Thanks!

Tom
Super User Tom
Super User

So can you tell from this DLL what parameters the function takes?

I would assume that it has a default of returning data in 100 observation chunks.

So perhaps there is a parameter to tell it to return more.  Or to tell to start from observations 101 so that you can read it in chunks and put it back together.

aneemo
Fluorite | Level 6

I think you are right to check this more closely!  I looked into the SASDataset object specifically and there is a Fetch method:

public abstract DataTable Fetch(long start, int count);

  Using this I seem to be able to get all the records from the dataset:

dataset[0].Fetch(0, (int)dataset[0].RowCount);

Not the cleanest code I know, but for my testing it does seem to work.  I really appreciate your taking time to reply as well as everyone else.  I think this is the solution after all!

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
  • 8 replies
  • 926 views
  • 3 likes
  • 4 in conversation