Is there a way in SAS to specify dynamic variable names in code? i.e. use different variables on different observations based on the value of another variable?
For
data want;
set have;
length _var_name $32 _var_num 5;
array vars(*) var: ;
/* if you want name of variable */
_var_name=VNAME(vars(index));
/* if you want numeric suffix of variable
and suffix is not same as position of variable in array
(so that vars(index) is not usable */
_var_num=INPUT(SUBSTR(_var_name, ANYDIGIT(_var_name)),32.);
run;
So what you need is VNAME() function.