Hello, SAS experts! Here is my code: Data one; A=0; ID_U=1; ID_V=2; Run; /* Running the renaming macro */ options macrogen mprint mlogic; %macro rename(lib,dsn,prefixtarget); select nvar into :num_vars from dictionary.tables where libname="&LIB" and memname="&DSN"; select distinct(name) into :var1- :var%TRIM(%LEFT(&num_vars)) from dictionary.columns where libname="&LIB" and memname="&DSN"; quit; run; proc datasets library=&LIB; modify &DSN; rename %do i=1 %to &num_vars; %PUT &&VAR&i; %IF %index(&&var&i,'ID') GT 0 %THEN &&var&i=&prefixtarget._&&var&i.; %end; ; quit; run; %mend rename; %rename(WORK,ONE,CAL); So my goal is to rename the variables based on whether the variables name contains a specific text expression(in this case, "ID"). So the final result I expect is: A CAL_ID_U CAL_ID_V 0 1 2 I have tried many different ways, but none of them work. Can you please tell me where goes wrong? Thanks!
... View more