SAS如何决定在使用通配符时选择哪个文件

时间:2018-03-19 17:10:49

标签: import sas

我的SAS代码看起来像这样:

DATA WORK.MY_IMPORT_&stamp; 
    INFILE "M:\YPATH\myfile_150*.csv"
    delimiter = ';' MISSOVER DSD lrecl = 1000000 firstobs = 2 ignoredoseof;
    [...]
RUN;

现在,在M:\ YPATH我有几个名为myfile_150.YYYYMMDD的文件。代码通过始终导入最新文件的方式工作。我想知道SAS如何决定选择哪个文件,因为通配符*可以被任何东西替换。它是按降序对文件进行排序并选择第一个文件吗?

1 个答案:

答案 0 :(得分:2)

在我的系统上,SAS 9.4 TS1M4,SAS正在读取满足通配符的所有文件。

我创建了3个文件(file_A.csv,file_B.csv和file_C.csv)。每个包含1条记录(分别为“A”,“B”和“C”)。

data test;
infile "c:\temp\file_*.csv"
    delimiter = ';' MISSOVER DSD lrecl = 1000000 ignoredoseof;
format char $1.;
input char $;
run;

(注意我从代码中删除了firstobs选项。)

生成的TEST数据集包含3个观察结果,'A','B'和'C'。

这是发出

时返回的文件的顺序
dir c:\temp\file_*.csv

SAS正在使用操作系统的默认行为并按顺序读取文件。

25   data test;
26   infile "c:\temp\file_*.csv"
27       delimiter = ';' MISSOVER DSD lrecl = 1000000 ignoredoseof;
28   format char $1.;
29   input char $;
30   run;

NOTE: The infile "c:\temp\file_*.csv" is:
      Filename=c:\temp\file_A.csv,
      File List=c:\temp\file_*.csv,RECFM=V,
      LRECL=1000000

NOTE: The infile "c:\temp\file_*.csv" is:
      Filename=c:\temp\file_B.csv,
      File List=c:\temp\file_*.csv,RECFM=V,
      LRECL=1000000

NOTE: The infile "c:\temp\file_*.csv" is:
      Filename=c:\temp\file_C.csv,
      File List=c:\temp\file_*.csv,RECFM=V,
      LRECL=1000000

NOTE: 1 record was read from the infile "c:\temp\file_*.csv".
      The minimum record length was 1.
      The maximum record length was 1.
NOTE: 1 record was read from the infile "c:\temp\file_*.csv".
      The minimum record length was 1.
      The maximum record length was 1.
NOTE: 1 record was read from the infile "c:\temp\file_*.csv".
      The minimum record length was 1.
      The maximum record length was 1.
NOTE: The data set WORK.TEST has 3 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds