将导入的文件名捕获到SAS中的变量中(Capture imported file name into a variable in SAS)
我试图找到一种方法来捕获一个文件的名称,我正在导入SAS的变量,因为我想用它来建立一个导出文件的名称。 例如,我在目录c:\ TEMP中有文件TEST.xlsx,我想要在SAS中导入并在对数据进行某些操作后将结果导出为TEST-01.xlsx。 请有人帮我做到这一点?
谢谢,丹
PROC IMPORT DATAFILE= "c:\TEMP\*.xlsx" DBMS=xlsx out=TABLE_START REPLACE; RUN;I'm trying to find a way to capture into a variable the name of a file what I'm importing in SAS as I want to use it to build the name of an exported file. For exemple, I have the file TEST.xlsx in the directory c:\TEMP, what I want to import in SAS and after some manipulation of data to export the result as TEST-01.xlsx. Can someone, please, help me to do that?
Thank you, Dan
PROC IMPORT DATAFILE= "c:\TEMP\*.xlsx" DBMS=xlsx out=TABLE_START REPLACE; RUN;最满意答案
首先找到名字。
data _null_; length fname $300 ; infile "c:\TEMP\*.xlsx" filename=fname; input @; call symputx('fname',fname); stop; run;然后你可以在导入或其他步骤中使用文件名。
PROC IMPORT DATAFILE= "&fname" DBMS=xlsx out=TABLE_START REPLACE; RUN;Just find the name first.
data _null_; length fname $300 ; infile "c:\TEMP\*.xlsx" filename=fname; input @; call symputx('fname',fname); stop; run;Then you can use the filename in your IMPORT or other steps.
PROC IMPORT DATAFILE= "&fname" DBMS=xlsx out=TABLE_START REPLACE; RUN;更多推荐
发布评论