You are just writing the value, not the name. You could just add the = to the put statement and SAS will include the variable name. While you are at it why not add the $QUOTE format so it is clearer where the value ends?
data test;
array newvar $20 var1 var2;
array oldvar $20 _var1 _var2;
input _var1 _var2;
subject+1;
do i=1 to dim(newvar);
newvar(i)=oldvar(i);
if length(oldvar(i)) >10 then
put 'ALERT P: ' newvar(I)= :$quote. 'is over 200 characters for ' subject=
;
end;
cards;
1 2
1234567890123 abc
xyz 123456789012
;
ALERT P: var1="1234567890123" is over 200 characters for subject=2
ALERT P: var2="123456789012" is over 200 characters for subject=3
NOTE: The data set WORK.TEST has 3 observations and 6 variables.
... View more