Hello,
I would like to add a prefix text, 'SEC_', to the ARRAY variable columns as my code shown below. I got an error message from the log window. Please help me to fix it. Thanks.
data Want;
set Have;
array vars uairway uapnea ugastro ugerd uendo uallergy uprem unone;
do over vars;
if find(SEC_uothersp_update1,vname(vars),"i") then 'SEC_'||vars=1;
end;
run;
Log massage shows:
do over vars;
if find(SEC_uothersp_update1,vname(vars),"i") then 'SEC_'||vars=1;
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
end;
Hi @ybz12003 Array variables are created at compile time and not at execution time. Therefore, your idea wouldn't work. However you could create another array statement defining its variable with SEC prefix like the below-
data Want;
set Have;
array vars uairway uapnea ugastro ugerd uendo uallergy uprem unone;
array s sec_uairway sec_uapnea sec_ugerd sec_uendo sec_uallergy sec_uprem sec_unone;
do over vars;
if find(SEC_uothersp_update1,vname(vars),"i") then s=1;
end;
run;
Hi @ybz12003 Array variables are created at compile time and not at execution time. Therefore, your idea wouldn't work. However you could create another array statement defining its variable with SEC prefix like the below-
data Want;
set Have;
array vars uairway uapnea ugastro ugerd uendo uallergy uprem unone;
array s sec_uairway sec_uapnea sec_ugerd sec_uendo sec_uallergy sec_uprem sec_unone;
do over vars;
if find(SEC_uothersp_update1,vname(vars),"i") then s=1;
end;
run;
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.