0

これが私がフォーマットを作成するために使用しているコードです.....

    libname myfmt "&FBRMrootPath./Formats";
%macro Create_Macro(DSN,Label,Start,fmtname,type);
options mprint mlogic symbolgen;
%If &type='n' %then %do;
  proc sort data=&DSN out=Out; by &Label;run;
  Data ctrl;
     set Out(rename=(&Label=label &Start=start )) end=last;
     retain fmtname &fmtname type &type;

  %If last %then %do;
      hlo='O';
      label='*ERROR';
      output;
  %End;
%End;

%Else  %do;
     proc sort data=&DSN out=Out; by &Start;run;
    Data ctrl;
     set Out(rename=(&Start=label &Label=start )) end=last;
     retain fmtname &fmtname type &type;
     output;
    %If last %then %do;
      hlo='O';
      label='*ERROR';
      output;
      %End;
%End;

proc format library=myfmt cntlin=ctrl;

%Mend Create_Macro;

%Create_Macro(SSIN.prd,prd_nm,prd_id,'prd_test','n');
/*%Create_Macro(SSIN.prd,prd_id,prd_nm,'prd_testc','c');*/

次のエラーが発生しています...コードは良さそうですが、なぜエラーが発生するのかわかりません...何か助けがありますか?

4

1 に答える 1

2

Not entirely sure what you are doing, but the error message is probably because you are mixing macro code with data step code. Trying change to this:

if last then do;
   hlo='O';
   label='*ERROR';
   output;
end;

In other words, get rid of the ampersands (which indicate macro variable references). And also be sure to add a run; statement at the end of each data step and after the PROC FORMAT call.

于 2013-02-11T20:28:54.867 に答える