为什么我在我的定义库

时间:2017-07-12 08:59:12

标签: sas shared-libraries data-files

我正在运行以下

%global source_dir util_dir paramf workdir datadir
    dataunitid 
    saserror 
    ;

%let datadir = %str(I:....\KATER\DATA);
%let outdir = %str(I:...\KATER\Results);


I set my library
libname datain "&datadir";
options mstored sasmstore=datain;

and then

%global liste_reg;
%let liste_reg=22 31;
%do k=1 %to %sysfunc(countw(&liste_reg.));
%let reg=%scan(&liste_reg.,&k.);
    data hh_record; set datain.hh_record_&reg.; run;
    data person_record; set datain.person_record_&reg.; run;
    %let outdir_ = &outdir.\output_&reg.;
     proc printto log = "&outdir_.Log.txt"; run; 

但是我收到了一个错误:

ERROR: File DATAIN.PERSON_RECORD_.DATA does not exist.
ERROR: File DATAIN.HH_RECORD_.DATA does not exist.

为什么会发生这种情况,如何将数据放入数据库?

我是SAS的新手,所以我很困惑。总的来说,我意识到这两个库都没有?

编辑完整代码:

%global source_dir util_dir paramf workdir datadir
    dataunitid 
    saserror 
;
%let source_dir = %str(I:...ONS_Transf_20170523);

*location of code;
%let util_dir = &source_dir.%str(\dsp_utils);
%let datadir = %str(...KATER\DATA);
%let outdir = %str(...\KATER\Results);
%let paramf = &datadir.%str(\parameter_file\param.csv);
options mautosource mrecall sasautos=(sasautos "&source_dir" "&util_dir")    nolabel;

%reset_saserror;
libname datain "&datadir";
options mstored sasmstore=datain;
libname outdir "&outdir.\output";
options mstored sasmstore=outdir;

%macro sdc_super_control_KAT;
    %global liste_reg;
    %let liste_reg=22 31;

    %do k=1 %to %sysfunc(countw(&liste_reg.));
        %let reg=%scan(&liste_reg.,&k.);

        data hh_record;
            set datain.hh_record_&reg.;
        run;

        data person_record;
            set datain.person_record_&reg.;
        run;

        %let outdir_ = &outdir.\output_&reg.;

        proc printto log = "&outdir_.Log.txt";
        run;

        /

        %sdc_control;

        *copy files to permanent library;
        proc copy in=work out=outdir_;
            select sdcresults_hh_:;
        run;

        proc printto;
        run;

    %end;

    data outdir.params;
        set diagnostics_params;
    run;

%mend sdc_super_control_KAT;

%sdc_super_control_KAT;

1 个答案:

答案 0 :(得分:1)

我认为你没有向我们展示完整的代码。上面的问题似乎是由于&reg宏变量未解析为某个值,但没有显示任何迹象表明为什么会发生这种情况。此外,错误消息的顺序错误(hh_record_)应该首先出现在日志中。

总之,这是因为您的reg变量正在解析为缺失值,或者因为找不到它(如果找不到,则日志应该说明了这一点。)