0

I am running the following

%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; 

But I get an error:

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

why is this happening, How can I put my data in datain library?

I am new in SAS so i am little confused. In general I realised that there is nothing in both libraries?

EDIT full code:

%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;
Reeza
  • 20,510
  • 4
  • 21
  • 38
Katerina
  • 1
  • 3
  • Run your macro again with the MPRINT and perhaps also SYMBOLGEN options turned on. You should then be able to tell why the macro variable REG is not getting set. You might also check into your use of so much macro quoting. Sometimes that can cause macro processor to convert things like `person_record_&reg` into two tokens instead of one. – Tom Jul 12 '17 at 13:05

1 Answers1

1

I don't think you're showing us the full code. The issue above appears to be due to the &reg macro variable not resolving to a value but there is nothing shown to indicate why that would happen. Also, the error messages are in the wrong order (hh_record_) should come first in the log.

In summary, it's because your reg variable is resolving to a missing value, or because it is not found (if not found, the log should say that though).

Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
  • Thank you Allan, next I include my full code. I didnt get your answer. – Katerina Jul 12 '17 at 09:26
  • 1
    Hi Katerina - it's possible that the variable `k` is being overwritten by a declaration within `%sdc_control;`. Could you share the log? Is best to do that in the question than by posting an answer... – Allan Bowe Jul 12 '17 at 11:07