DATA Step, Macro, Functions and more

the last item in my loop was not executed

Accepted Solution Solved
Reply
Super Contributor
Posts: 318
Accepted Solution

the last item in my loop was not executed

I have a number of variables that were log transformed, and I wanted to use these new variables to do ANOVA.

I first created a macro variable to store all the log transformed variables names and then used a do loop to repeat the anova analysis.

The problem is, my last log variables was not included in the anova analysis. I checked the values of the macro variables "collist" and "n", which were both correct.

 

What could be the problem?

 

 


%macro loop_var(data);
proc contents data=&data short out=test; run;
proc sql;
select name into :collist separated by ' '
from test
where name like 'log_%';
%let n=&sqlobs;
quit;
ods graphics off;
%do i=1 %to &n;
    %let currentvar=%scan(&collist,&i);
proc glm data=&data ;
class type;
model &currentvar=type;
lsmeans type /pdiff stderr cl ADJUST=SCHEFFE;
%end;
%mend;

%loop_var(mydata);

Accepted Solutions
Solution
‎06-02-2016 04:19 PM
Super User
Posts: 11,343

Re: the last item in my loop was not executed

Posted in reply to fengyuwuzu

Try adding

run;

at the end of the Proc Glm code. You may not be running into a "boundary" to tell the procedure that the last one ended.

View solution in original post


All Replies
PROC Star
Posts: 1,324

Re: the last item in my loop was not executed

Posted in reply to fengyuwuzu

What values do you have for collist and n?

 

Perhaps add:

%put collist=&collist i=&i currentvar=&currentvar n=&n;

Immediately before your PROC GLM statement.  That should help debug.

 

Solution
‎06-02-2016 04:19 PM
Super User
Posts: 11,343

Re: the last item in my loop was not executed

Posted in reply to fengyuwuzu

Try adding

run;

at the end of the Proc Glm code. You may not be running into a "boundary" to tell the procedure that the last one ended.

Super Contributor
Posts: 318

Re: the last item in my loop was not executed

yes. this solved the problem. Thank you.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 249 views
  • 0 likes
  • 3 in conversation