The following "do I=1 to 2" code will fail after Auto Indenter is run using CTRL-I on SAS EG. The error only occurs when the do loop is part of an "else if" condition.
data have;
input col1$ col2;
datalines;
a 0123
b 345
b 456
d 711189
x
u 3033
w 1234567890
run;
data want1;
set have;
if col1 = 'b' then do;
new = cats('b', col2); output; end;
else if col1 = 'd' then do i= 1 to 2;
if i = 1 then do; new = cats('d', col2); output; end;
if i = 2 then do; new = cats('db', col2); output; end;
end;
run;
data want2;
set have;
if col1 = 'b' then do i= 1 to 2;
if i = 1 then do; new = cats('b', col2); output; end;
if i = 2 then do; new = cats('bc', col2); output; end;
end;
else if col1 = 'd' then do;
new = cats('d', col2); output; end;
run;After CRTL-I there is an extra semi colon between the do and I = 1 to 2
data want1;
set have;
if col1 = 'b' then
do;
new = cats('b', col2);
output;
end;
else if col1 = 'd' then
do;
i= 1 to 2;
if i = 1 then
do;
new = cats('d', col2);
output;
end;
if i = 2 then
do;
new = cats('db', col2);
output;
end;
end;
run;Is there some Indenter option I have set incorrectly ?
Using SAS EG8.2 I can replicate what you describe. It looks like formatting code adds a semicolon to the code....
Looks like a bug to me. Can you please raise this with SAS Technical Support
Before formatting the code
After formatting the code
SAS Technical support were able to replicate and are now working on a fix.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.