这里有一个快速而肮脏的 python 五行代码,用于将 SAS .xpt(又名 XPORT)文件转换为 .csv
import pandas as pd
FILE_PATH = "(fully qualified name of 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')
希望这可以帮助某人
Here a quick-and-dirty python five-liner to convert a SAS .xpt (aka XPORT) file to .csv
import pandas as pd
FILE_PATH = "(fully qualified name of 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')
There are two parts to your question
1. Read these files
2. Convert these files
I looked into the link you shared there are no directly downloadable files, but I am assuming that you mean the files for windows.
For conversion you can do the following
a. Use SAS proc import to export and proc export to export the files feature,
b. Use third party softwares, e.g., DBMSCopy for this;
c. Download trial version of JMP and convert the files to desired format, e.g., CSV/txt etc and get done with it.
发布评论
评论(7)
我也遇到了同样的问题,所以我做了一个简单的SAS数据查看器。您可以从此处的下载部分下载它:http://code.google.com/p/sasquatch
它具有许多与 SAS Universal Viewer 相同的功能,但仍在进行中。
您需要安装 Adobe AIR,您可以在 adobe 网站上获取它。
I had the same problem, so i made a simple SAS data viewer. You download it from the downloads section here: http://code.google.com/p/sasquatch
It has alot of the same features as SAS Universal Viewer, but its still a work in progress.
You need to have Adobe AIR installed, you can get that on the adobe website.
数据是 SAS XPORT (.xpt) 还是 .sas7bdat 格式?
Are the data in the SAS XPORT (.xpt) or .sas7bdat format?
为了将来参考,可以使用 R 的“SASxport”包读取和写入 SAS XPORT 文件(http://cran.r-project.org/web/packages/SASxport/index.html)。
For future reference, SAS XPORT files can be read and written using the 'SASxport' package for R (http://cran.r-project.org/web/packages/SASxport/index.html).
(已将此发布到 superuser.com)
SAS Institute(生产 SAS 的公司)制作了一个 SAS 数据集查看器。
请注意,SAS 程序文件通常具有扩展名
.sas
,而数据文件本身通常具有扩展名.sas7bdat
。(编辑:我后来注意到你的标题说是在 Mac 上运行的,所以这可能没有多大帮助,因为我相信该工具仅适用于 Windows。)
(Already posted this to superuser.com)
SAS Institute (the company that makes SAS) produces a viewer for SAS data sets.
Note that SAS program files usually have the extension
.sas
, whereas the data files themselves usually have the extension.sas7bdat
.(EDIT: I notice belatedly that your title says on a Mac, so this may not help much as I believe the tool is Windows only.)
这里有一个快速而肮脏的 python 五行代码,用于将 SAS .xpt(又名 XPORT)文件转换为 .csv
希望这可以帮助某人
Here a quick-and-dirty python five-liner to convert a SAS .xpt (aka XPORT) file to .csv
Hopefully this might help someone
JMP在MAC上运行并且可以读取sas文件。请访问 jmp.com 了解更多信息。
JMP runs on MAC and can read sas files. Visit jmp.com for more information.
你的问题有两个部分
1. 阅读这些文件
2. 转换这些文件
我查看了您共享的链接,没有直接可下载的文件,但我假设您指的是 Windows 的文件。
要查看,您可以使用以下内容
一个。 SAS 通用查看器:https://support.sas.com/downloads/package。 htm?pid=667
b.在mac上使用SAS直接读取文件
要进行转换,您可以执行以下操作
一个。使用SAS proc import导出和proc导出导出文件功能,
b.为此使用第三方软件,例如 DBMSCopy;
c.下载 JMP 试用版并将文件转换为所需格式(例如 CSV/txt 等)并完成使用。
There are two parts to your question
1. Read these files
2. Convert these files
I looked into the link you shared there are no directly downloadable files, but I am assuming that you mean the files for windows.
For viewing you can use the folloiwng
a. SAS Universal viewer: https://support.sas.com/downloads/package.htm?pid=667
b. Use SAS on mac to directly read the files
For conversion you can do the following
a. Use SAS proc import to export and proc export to export the files feature,
b. Use third party softwares, e.g., DBMSCopy for this;
c. Download trial version of JMP and convert the files to desired format, e.g., CSV/txt etc and get done with it.