0

Here is the code I'm using to creat a format.....

    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');*/

I'm getting following errors...Code looks good but I donno why I'm getting errors... Any help???

Joe
  • 62,789
  • 6
  • 49
  • 67
SAS_learner
  • 521
  • 1
  • 13
  • 30
  • Here are the errors I'm getting...ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: last ERROR: The macro CREATE_MACRO will stop executing.%LET _SASPROGRAMFILE=; 58 59 ;*';*";*/;quit;run; ____ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. – SAS_learner Feb 11 '13 at 20:08
  • Edit your question to add the error message; don't use a comment. – BellevueBob Feb 11 '13 at 20:22

1 Answers1

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.

BellevueBob
  • 9,498
  • 5
  • 29
  • 56