DATA Step, Macro, Functions and more

Macro execution not ending manual stopping of run giving error

Reply
Occasional Contributor
Posts: 6

Macro execution not ending manual stopping of run giving error

Hi All,

    I created a macro that create global variables based based on the program name I pass. when I execute macro it is not stop running. When I manually stop I am getting following error.   What is wrong with my code?

The input dataset has the value "l_demo_fas".

Please help!!!

129   %datapgm(pgm=l_demo_fas);

ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition.

ERROR: The %TO value of the %DO I loop is invalid.

ERROR: The macro DATAPGM will stop executing.

*****Here is my code****

%macro datapgm(pgm=);

%global nbt nbf outname pgmpath;

data _NULL_;

  set adam.toc_prog;

  where pgm_id = "&pgm";

  call symput('nbt',compress(input(strip(put(numtitle,3.)),$3.)));

  call symput('nbf',compress(input(strip(put(numfoot,3.)),$3.)));

  call symput('outname', compress(strip(outname)));

  call symput('pgmpath',compress(strip(pgmpath)));

 

%do i = 1 %to &nbt;

    %global t&i;

     call symput('t'||"&i",strip(title_&i));

%end;

%do j = 1 %to &nbf;

    %global f&j;

    call symput('f'||"&j",strip(foot_&j));

%end;

run;

%mend;

 

%datapgm(pgm=l_demo_fas);

%put &nbt.  &nbf;

%put &t1  &t2 &t3;

%put &f1;

%put &outname;

%put &pgmpath;

Thanks in advance!!!

Valued Guide
Posts: 3,208

Re: Macro execution not ending manual stopping of run giving error

1/ as your are trying to symput nbt nbf in the datastep the macro will not be able to get those values. There will be a timing problem on valuses

2/ Debug your macro wih optionc mprint mlogic symbolgen etc...o

---->-- ja karman --<-----
Occasional Contributor
Posts: 6

Re: Macro execution not ending manual stopping of run giving error

Hi Jaap,

   If I run part by part working fine.. kind of weird.

  As you have mentioned it looks like timing issue.

Now I used 2 data steps in the macro. so far working fine and I used %eval for do loop. see the following corrected program.

Thanks for you suggestion..

%macro datapgm(pgm=);

data ttft;

  set adam.toc_prog;

where pgm_id = "&pgm";

%global nbt nbf outname pgmpath;

 

  call symput('nbt', compress(input(strip(put(numtitle,3.)),$3.)));

  call symput('nbf', compress(input(strip(put(numfoot,3.)),$3.)));

  call symput('outname', compress(strip(outname)));

  call symput('pgmpath',compress(strip(pgmpath)));

run;

data _NULL_;

   set ttft;

   %do i = 1 %to %eval(&nbt);

     %global t&i;

     call symput('t'||"&i",strip(title_&i));

   %end;

   %do j = 1 %to %eval(&nbf);

      %global f&j;

      call symput('f'||"&j", strip(foot_&j));

   %end;

run;

%mend;

Ask a Question
Discussion stats
  • 2 replies
  • 370 views
  • 3 likes
  • 2 in conversation