- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello everybody,
I am new to use .xpt files so I am a little confused how to get them to SAS-files.
I have tried with proc cimport like:
libname oai 'C:\Users\Documents';
libname xptfile xport 'C:\Users\Documents\Enrollees.xpt';
proc cimport infile=xptfile library=oai;
run;
Log tells me that the data sep was updated with variables and observations, but when I want to open the file it tells me that it cant be opened..I also tried the following data-step:
libname xportin xport 'C:\Users\Documents\Enrollees.xpt';
libname target 'C:\Users\Documents';
data target.Enrollees ;
set xportin.Enrollees;
run;
but then I get the following error
The file XPORTIN.ENROLLEES.DATA has too long a member name for the XPORTIN library.
11 run;
Can anybody help me and has an idea what to do?
Kind regards,
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Probably, its a real nuisance I know. If you had access to a 32bit install of SAS you could export the formats to dataset and then copy that to your 64bit install. You might be able to do this with the SAS Universal Viewer:
http://support.sas.com/software/products/univiewer/#s1=1
I.e. open it in 32bit version of that, then save to flat file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I always use the code:
libname a "c:\somewher"; libname xptfile xport "c:\anxpt.xpt" access=readonly; proc copy inlib=xptfile outlib=a; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please post the entire log results including the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
this is the code I tried that was posted
libname oai 'C:\Users\m244906\Documents';
libname xptfile xport 'C:\Users\m244906\Documents\Enrollees.xpt' access=readonly;
proc copy inlib=xptfile outlib=oai;
run;
and here is the log
libname oai 'C:\Users\m244906\Documents';
NOTE: Libref OAI was successfully assigned as follows:
Engine: V9
Physical Name: C:\Users\m244906\Documents
2 libname xptfile xport 'C:\Users\m244906\Documents\Enrollees.xpt' access=readonly;
NOTE: Libref XPTFILE was successfully assigned as follows:
Engine: XPORT
Physical Name: C:\Users\m244906\Documents\Enrollees.xpt
3 proc copy inlib=xptfile outlib=oai;
NOTE: Writing HTML Body file: sashtml.htm
4 run;
NOTE: Input library XPTFILE is sequential.
ERROR: File is probably a cport file. XPORT engine unable to read file created by proc cport.
Please use proc cimport to convert this file to native format.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE COPY used (Total process time):
real time 1.38 seconds
cpu time 0.93 seconds
NOTE: The SAS System stopped processing this step because of errors.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ah, looking at the SAS help. It looks like your original code is incorrect:
filename importin 'transport-file'; libname target 'SAS-data-library'; proc cimport infile=importin library=target; run;
From: http://support.sas.com/documentation/cdl/en/movefile/59598/HTML/default/viewer.htm#a000763417.htm
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
thanks, I just saw this code and tried it immediately. The log is ok but when i want to open the data file it tells me
filename importin 'C:\Users\m244906\Documents\Enrollees.xpt';
libname target 'C:\Users\m244906\Documents';
proc cimport infile=importin library=target memtype=data;
run;
Unable to open the the table target.enrollees, do you want to open another table
and then the log shows
ERROR: Format GENDER not found or couldn't be loaded for variable P02SEX.
ERROR: Format YNDK not found or couldn't be loaded for variable P02HISP.
ERROR: Format COHORT not found or couldn't be loaded for variable V00COHORT.
ERROR: Format IMAGES not found or couldn't be loaded for variable V00IMAGESA.
ERROR: Format RACECAT not found or couldn't be loaded for variable P02RACE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
These errors simply mean that there are formats permanently assigned to variables in the dataset and these formats are not available in your SAS session. As a first remedy you could submit
options nofmterr;
Then you should be able to open the dataset and see the "unformatted" (or rather default-formatted) values of variables P02SEX, P02HISP, etc.
Ideally you should try to get the format catalog or a CNTLOUT dataset of it or the format definitions as SAS code in order to see the formatted values. Was nothing like this contained in the XPT file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @J_L,
There are two different types of XPT files I'm aware of and the methods to convert them to SAS datasets (or catalogs etc.) cannot be used interchangeably:
- XPT files created using PROC COPY and the XPORT engine
- XPT files created using PROC CPORT
According to your description (PROC CIMPORT seemed to work) your XPT file is of the second type. So, you should not involve the XPORT engine (by specifying this in a LIBNAME statement), but use PROC CIMPORT as RW9 has suggested in his second post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help with the options nofmterr .
I now received a xpt formats file and also other files named SAS Catalog (also with formats).
I tried to open the formats xpt file with the same statement mentioned above but that wont work.
File TARGET.FORMATS.CATALOG was created for a different operating system.
ERROR: Unable to open catalog TARGET.FORMATS.
NOTE: PROCEDURE CIMPORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
than I tried with the SAS help to import multiple catalogs with the cimport statement and the memtype=cataloge statement
but there is also the same error
ERROR: File TARGET.FORMATS.CATALOG was created for a different operating system.
ERROR: Unable to open catalog TARGET.FORMATS.
NOTE: PROCEDURE CIMPORT used (Total process time):
real time 0.03 seconds
cpu time 0.01 second
What now, I am really confused
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You have hit the prime example of why not to use proprietary file formats. What version of SAS are you using to open the file - is it Windows, is it 64 bit or 32bit? What system compiled the file? Was that Windows, was it 64 or 32 bit? Simply put, a catalog created under a 32bit system, cannot be opened on a 64bit machine and vice versa. You need to match the bitness of the file to be able to open it. This has caused us a lot of problems as well, as we have compiled macros and such like from vendors from years back that we can't use now the sytem changed. There is not slution to this other than getting the code and re-running or matching bitness.
You could just ignore the formats and catalog with
options nofmterr;
Refer to this page:
http://support.sas.com/kb/14/549.html
My advice, always use plain open text for your file formats, e.g. XML/CSV for data, text for programs, and avoid proprietary file formats altogether. I know certain regulatory bodies still require XPT files, but that will disappear soon - XML is becoming more prevalent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ah ok I see... I am using SAS 9.3 and Windows 64 bit. The datasets are from a public resource database. They state that they used
"SAS CPORT and the SAS V9 engine in the Windows environment." to create the datasets.
I guess using the datasets without the formats will then be the easiest way to work with
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Probably, its a real nuisance I know. If you had access to a 32bit install of SAS you could export the formats to dataset and then copy that to your 64bit install. You might be able to do this with the SAS Universal Viewer:
http://support.sas.com/software/products/univiewer/#s1=1
I.e. open it in 32bit version of that, then save to flat file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello, I am getting an error when attempting to download SAS code.
When I click on the link, I get the following:
"ERROR - File is probably a cport file. XPORT engine unable to read file created by proc cport. Please use proc cimport to convert this file to native format."
What do I do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please open a new thread rather than posting in old topics. SAS code is plain text files so would not need cimport or anything like that. If its SAS data or catalogs then yes, you may need it. Follow the given warning and use cimport - examples in the documentation. If not, post a new question, show the file you are having difficulty with.