Hey guys,
Sas shows me a waring that Do group statements were not executed due to missing END at the time of Quit,
BUT although I have checked it for several times, I still cannot find the problem.
proc iml;
load D;
load RR;
load LL;
start LLH(st,fi,S);
b_1=(S[st:(fi-1),4]`)*S[(st+1):fi,4]/((S[st:(fi-1),4]`)*S[st:(fi-1),4]);
b_2s=S[(st+1):fi,4]-b_1*S[st:(fi-1),4];
b_2=b_2s[:];
sigma_s1=S[(st+1):fi,4]-b_1*S[st:(fi-1),4]-b_2;
sigma_s2=sigma_s1##J((fi-st),1,2);
sigma=(fi-st-1)/(fi-st-2)*sigma_s2[:];
if sigma=0 then LLF=.;
else do;
LLF=(-0.5*(fi-st-1))*log(2*arcos(-1)*sigma)-1/(2*sigma)*((S[st:(fi-1),4]`)*S[st:(fi-1),4]);
end;
return(LLF);
finish LLH;
fname = "split1":"split2320";
do i = 1 to ncol(fname);
dsname = "spl1." + strip(fname[i]);
use (dsname);
do t=1 to 120;
g=D[t,1];
read all where(COL2=g) into SS;
if nrow(SS)=0 then RR[i,t]=.;
else do;
st=1;
fi=15;
M_sf=J(1,2,0);
do until (fi>240);
if abs(LLH(st,fi+1,SS)/LLH(st,fi,SS)-1)>0.1
then do;
M_sf[1,1]=st;
M_sf[1,2]=fi;
stfi=stfi//M_sf;
st=fi+1;
fi=fi+15;
if st>225
then do;
M_sf[1,1]=st;
M_sf[1,2]=240;
stfi=stfi//M_sf;
end;
else do;
fi=fi+1;
if fi>240
then do;
M_sf[1,1]=st;
M_sf[1,2]=240;
stfi=stfi//M_sf;
end;
end;
end;
do tt=1 to nrow(stfi);
b_1=(S[st:(fi-1),4]`)*S[(st+1):fi,4]/((S[st:(fi-1),4]`)*S[st:(fi-1),4]);
b_2s=S[(st+1):fi,4]-b_1*S[st:(fi-1),4];
b_2=b_2s[:];
sigma_s1=S[(st+1):fi,4]-b_1*S[st:(fi-1),4]-b_2;
sigma_s2=sigma_s1##J((fi-st),1,2);
r_11=sigma_s2;
r_1=r_1+r_11;
r_22=((S[(st+1):fi,4]-S[(st+1):fi,4][:])`)*(S[(st+1):fi,4]-S[(st+1):fi,4][:]);
r_2=r_2+r_22;
end;
RR[i,t]=r_1/r_2;
end;
end;
close;
end;
store RR;
create ba.RR from RR;
append from RR;
quit;
Post your full log.
The included code shows 10 do's and 10 end's so the counts match, but I didn't read each line.
I (SAS) formatted your code, which is what I usually do to try and find missing do/end.
What type of SAS interface are you working with? In EG and Base there are keyboard shortcuts that allow you to jump from a Do to the corresponding END. I can't find a similar function in SAS Studio 😞
proc iml ;
load D;
load RR;
load LL;
start LLH(st, fi, S);
b_1=(S[st:(fi-1), 4]`)*S[(st+1):fi, 4]/((S[st:(fi-1), 4]`)*S[st:(fi-1), 4]);
b_2s=S[(st+1):fi, 4]-b_1*S[st:(fi-1), 4];
b_2=b_2s[:];
sigma_s1=S[(st+1):fi, 4]-b_1*S[st:(fi-1), 4]-b_2;
sigma_s2=sigma_s1##J((fi-st), 1, 2);
sigma=(fi-st-1)/(fi-st-2)*sigma_s2[:];
if sigma=0 then
LLF=.;
else
do;
LLF=(-0.5*(fi-st-1))*log(2*arcos(-1)*sigma)-1/(2*sigma)*((S[st:(fi-1),
4]`)*S[st:(fi-1), 4]);
end;
return(LLF);
finish LLH;
fname="split1":"split2320";
do i=1 to ncol(fname);
dsname="spl1." + strip(fname[i]);
use (dsname);
do t=1 to 120;
g=D[t, 1];
read all where(COL2=g) into SS;
if nrow(SS)=0 then
RR[i, t]=.;
else
do;
st=1;
fi=15;
M_sf=J(1, 2, 0);
do until (fi>240);
if abs(LLH(st, fi+1, SS)/LLH(st, fi, SS)-1)>0.1 then
do;
M_sf[1, 1]=st;
M_sf[1, 2]=fi;
stfi=stfi//M_sf;
st=fi+1;
fi=fi+15;
if st>225 then
do;
M_sf[1, 1]=st;
M_sf[1, 2]=240;
stfi=stfi//M_sf;
end;
else
do;
fi=fi+1;
if fi>240 then
do;
M_sf[1, 1]=st;
M_sf[1, 2]=240;
stfi=stfi//M_sf;
end;
end;
end;
do tt=1 to nrow(stfi);
b_1=(S[st:(fi-1), 4]`)*S[(st+1):fi, 4]/((S[st:(fi-1), 4]`)*S[st:(fi-1),
4]);
b_2s=S[(st+1):fi, 4]-b_1*S[st:(fi-1), 4];
b_2=b_2s[:];
sigma_s1=S[(st+1):fi, 4]-b_1*S[st:(fi-1), 4]-b_2;
sigma_s2=sigma_s1##J((fi-st), 1, 2);
r_11=sigma_s2;
r_1=r_1+r_11;
r_22=((S[(st+1):fi, 4]-S[(st+1):fi, 4][:])`)*(S[(st+1):fi,
4]-S[(st+1):fi, 4][:]);
r_2=r_2+r_22;
end;
RR[i, t]=r_1/r_2;
end;
end;
close;
end;
store RR;
create ba.RR from RR;
append from RR;
quit;
the full log is shown as:
.......(same as the code)
WARNING: DO group statements were not executed due to missing END at the time of QUIT.
121 quit;
NOTE: Exiting IML.
NOTE: Storage library WORK.IMLSTOR closed.
NOTE: “PROCEDURE IML”:
real time 0.47
cpu time 0.07
I use the base of SAS interface, and what is the keyboard shortcuts for the corresponding END of the DO group?
Thank you.
It looks like there is not an END statement for
do i=1 to ncol(fname);
Put an END either before the STORE statement or before the QUIT, depending upon the logic of your program.
Hi Rick,
Have you got the keyboard shortcuts for finding the END corresponding to the DO group, which is mentioned by Reeza?
Thanks a lot!
Hi Rick,
I found that some problem still exists. The shortcut cannot lead to the right END with its corresponding DO group. Show you some example as below:
I start the shortcut at line 4, and sas jumps to line 9(wrong). I don't know why.
proc iml;
k=0;
t=0;
do f=1 to 3; /*start the shortcut here*/
if k=0
then do;
k=k+1;
t=t+1;
end; /*but move to this wrong place*/
else do;
k=k+2;
t=t+2;
end;
end;
print k t;
quit;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.