由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 请教如何同时用sas打开多个excel文件?多谢!
相关主题
questions about SAS import Excel data请教:多个csv文件(>100)怎么用"proc sql" merge成一个文件?
SAS 数据读入的问题 (proc import)SAS macro to import multiple csv file??
Help:import excel file into sasSAS date format 的问题
Proc import 读excel文件,怎么略去前面几行?sas import .xlsx
SAS proc import excel file 紧急求助@@请教用SAS import CSV 文件时遇到的状况
help on importing csv file to SAS[求助]用SAS建立多个工作簿的Excel文件
SAS的一个小问题sas importing question
[合集] excel datawhat is the problem?
相关话题的讨论汇总
话题: yes话题: excel话题: out话题: proc话题: scantext
进入Statistics版参与讨论
1 (共1页)
l**********s
发帖数: 255
1
我可以用如下的code分别打开三个excel文件 ,但是如何同时打开它们呢?实际上我有
上百个excel文件需要打开,是否可以用同一个简短的code同时打开它们呢?多谢!
PROC IMPORT OUT= WORK.a1
DATAFILE= "h:\a1.xls"
DBMS=EXCEL REPLACE;
SHEET="sheet1";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;
PROC IMPORT OUT= WORK.a2
DATAFILE= "h:\a2.xls"
DBMS=EXCEL REPLACE;
SHEET="sheet1";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;
D******n
发帖数: 2836
2
u r reading in the data, u r not just "OPENING" it. U don't simultaneously
open all these files. I guess what u mean is how to write a macro to read in
hundreds of excel files.
l**********s
发帖数: 255
3
Thanks a lot. Yes, I mean "read"---could you or anybody help me? I am trying
to use macro but still did not figure it out. This is my RA stuff, and I
need to figure it out soon or "read" the excels seperatively.
s******r
发帖数: 1524
4
%macro M_test;
%do i=1 %to 100;
PROC IMPORT OUT= WORK.a&i
DATAFILE= "h:\a&i..xls"
DBMS=EXCEL REPLACE;
SHEET="sheet1";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;
%end;
%mend M_test;
%M_test;

【在 l**********s 的大作中提到】
: 我可以用如下的code分别打开三个excel文件 ,但是如何同时打开它们呢?实际上我有
: 上百个excel文件需要打开,是否可以用同一个简短的code同时打开它们呢?多谢!
: PROC IMPORT OUT= WORK.a1
: DATAFILE= "h:\a1.xls"
: DBMS=EXCEL REPLACE;
: SHEET="sheet1";
: GETNAMES=YES;
: MIXED=NO;
: SCANTEXT=YES;
: USEDATE=YES;

l**********s
发帖数: 255
5
多谢楼上的答复,再请问下如果每个要打开的excel文件名字没有规律可寻, 比如5个文
件依此叫做abc, abk, abj, nbc, cnn,该怎么办呢?
c**d
发帖数: 104
6
Suppose you have a lot of excel files under H:\Temp
/* get excel names */
filename myxls 'dir "H:\Temp" /b' LRECL=5000;
data myfile;
infile myxls length = len;
input fname $200. len;
run;
/* save each into a macro variable */
proc sql;
select fname into :a1 - :a9999
/* do loop to input excel */

【在 l**********s 的大作中提到】
: 多谢楼上的答复,再请问下如果每个要打开的excel文件名字没有规律可寻, 比如5个文
: 件依此叫做abc, abk, abj, nbc, cnn,该怎么办呢?

f*****a
发帖数: 693
7
Try this one. Can some one give some improvement, such as change variable
file into a file which includes all the to be input file names? Thanks.
%macro openfile(file);
%let file=all you file name list with space as delimiter (no space inside
file names);
%let i=1;
%let name=%scan(&file,&i);
%do %until(not %length(&name));
proc import out=work.&name
datafile="h:\&name"
dbms=excel replace;
sheet="sheet1";
getnames=yes;
mixed=no;
scantext
f*****a
发帖数: 693
8
Good one, thanks.

【在 c**d 的大作中提到】
: Suppose you have a lot of excel files under H:\Temp
: /* get excel names */
: filename myxls 'dir "H:\Temp" /b' LRECL=5000;
: data myfile;
: infile myxls length = len;
: input fname $200. len;
: run;
: /* save each into a macro variable */
: proc sql;
: select fname into :a1 - :a9999

l**********s
发帖数: 255
9
Thanks, it works!!

【在 f*****a 的大作中提到】
: Try this one. Can some one give some improvement, such as change variable
: file into a file which includes all the to be input file names? Thanks.
: %macro openfile(file);
: %let file=all you file name list with space as delimiter (no space inside
: file names);
: %let i=1;
: %let name=%scan(&file,&i);
: %do %until(not %length(&name));
: proc import out=work.&name
: datafile="h:\&name"

1 (共1页)
进入Statistics版参与讨论
相关主题
what is the problem?SAS proc import excel file 紧急求助
reading data into sas 问题help on importing csv file to SAS
再看SAS in stock market 这本书 有啥数据库可以拿来联系的吗SAS的一个小问题
帮我看看如何导入.dat file into sas吧[合集] excel data
questions about SAS import Excel data请教:多个csv文件(>100)怎么用"proc sql" merge成一个文件?
SAS 数据读入的问题 (proc import)SAS macro to import multiple csv file??
Help:import excel file into sasSAS date format 的问题
Proc import 读excel文件,怎么略去前面几行?sas import .xlsx
相关话题的讨论汇总
话题: yes话题: excel话题: out话题: proc话题: scantext