- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am a new user ,I have a extend filename xpt file example demo_j.xpt file,I want to open it ,and convert to xls file?please help me ,tks
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SASUSER is per default opened read-only nowadays.
Use WORK or a library defined on the shared folder:
libname xp xport "/folders/myfolders/sasuser.v94/DEMO_J.XPT";
libname myfold "/folders/myfolders";
proc copy
in=xp
out=myfold
;
run;
Note that it is not necessary to shout at SAS to get it to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How to read a XPT file, and how to create an excel file, has been discussed many times in this community.
Please search, try, and if you encounter problems, show your code and ask your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PROC COPY IN=XP OUT=SASUSER;
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
SASUSER is per default opened read-only nowadays.
Use WORK or a library defined on the shared folder:
libname xp xport "/folders/myfolders/sasuser.v94/DEMO_J.XPT";
libname myfold "/folders/myfolders";
proc copy
in=xp
out=myfold
;
run;
Note that it is not necessary to shout at SAS to get it to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How do I do it if I have NO as in NONE access to SAS, just the .xpt file and excel?
I've been handed a file and told to make sense of it.
Doesn't seem to be a way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Answering my own question; Here's quick and dirty python code:
import pandas as pd
FILE_PATH = "(directory containing file)"
FILE = "ABC" # filename itself (without suffix)
# Note: might need to substitute the column name of the index (in quotes) for "None" here
df = pd.read_sas(FILE_PATH + FILE + '.XPT', index=None)
df.to_csv(FILE_PATH + FILE + '.csv')
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The first thing you need to find out is whether the file with the XPT extension is a SAS XPORT file or a SAS CPORT file (or neither). You can check the first 80 bytes to tell, but it is probably just easier to try one method and if it doesn't work then try the other.
It is much easier to make an XLSX file than and XLS file. Plus they are more portable.
libname in xport 'demo_j.xpt';
libname out xlsx 'demo_j.xlsx';
proc copy inlib=in outlib=out;
run;
For a CPORT file you will need to use PROC CIMPORT instead.
proc cimport lib=out infile='demog_j.xpt';
run;