Hello,
I have a data/table like below:
If I would like to remove (XX) when rowlbl='All' for col1:col3, how can I do it using do loop?
I can do it one by one, but when I try to use do loop, I failed. Could anyone guide me on this?
*do it one by one; data _ds; set ds; if rowlbl='All' then do; col1=scan(col1, 1, ' ('); end; run; *try to use do loop; data _ds; set ds; if rowlbl='All' then do; do i=1 to 3; coli=scan(coli, 1, ' ('); end; end; run;
My way of removing '(XX)' might be too silly. Any better suggestion?
What variable is COLI?
Did you mean to create an array? if so you need addition syntax, brackets, to reference a member of the array.
data _ds;
set ds;
array columns col: ;
if rowlbl='All' then do index=1 to dim(columns);
columns[index]=scan(columns[index], 1, ' (');
end;
drop index;
run;
What variable is COLI?
Did you mean to create an array? if so you need addition syntax, brackets, to reference a member of the array.
data _ds;
set ds;
array columns col: ;
if rowlbl='All' then do index=1 to dim(columns);
columns[index]=scan(columns[index], 1, ' (');
end;
drop index;
run;
😅 COL1 is just col1. I can update cols one by one. I only listed COL1. sorry for that.
I was wondering whether we could use do loop to update the variable values. If so, how?
@stataq wrote:
😅 COL1 is just col1. I can update cols one by one. I only listed COL1. sorry for that.
I was wondering whether we could use do loop to update the variable values. If so, how?
?? Read the code I posted.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.