楼主: 恋凡
7972 13

求助:sas导入excel数据的问题 [推广有奖]

11
benbenj 发表于 2011-4-18 16:56:56
8# 贾贡献   SAS9.1.3支持EXCEL 导入的,我用了很长时间了,不过 我一般都是直接导入,不用语句。曾经尝试用语句导入但出现了丢数值的问题,最后将.xls改称.csv进行的导入。

12
wmqy2004 发表于 2011-4-18 21:37:10
试试这个。最好是将你的excel文件保存为excel2000以下的格式。
%macro importxls(datafile=,out=,sheet=,opt=1);
%if &opt^=1 %then %do;
proc import out=&out datafile="&datafile" dbms=csv replace;%end;
%else %do;proc import out=&out datafile="&datafile" dbms=excel2000 replace;
%if &sheet ne %then %do;sheet="&sheet.$";%end;
%if &sheet=' ' %then %do;sheet="sheet1$";%end;%end;getnames=yes;run;
%mend importxls;

13
jmpamao 发表于 2011-4-18 21:54:56
谢谢 所以热心的朋友。

14
xiayuguoguo 发表于 2011-4-29 18:17:56
丢数值是因为变量格式不统一,可以在import过程中,加语句 mixed=yes; 就不会丢了。 11# benbenj

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-2 20:40