将导入的文件名捕获到SAS中的变量中(Capture imported file name into a variable in SAS)

编程入门 行业动态 更新时间:2024-10-27 15:16:05
将导入的文件名捕获到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;

更多推荐

本文发布于:2023-07-05 08:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1035440.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件名   变量   SAS   Capture   file

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!