data have ;
infile cards dsd dlm='|' truncover ;
length id q1-q3 8 string $30 expected_score 8 ;
input id -- expected_score ;
cards;
1|1|3|1|sum(Q1, Q3)|2
2|3|2|2|sum(Q1, Q2, Q3)|7
3|2|1|4|sum(Q2, Q3)|5
;;;;
;
data want;
set have;
array x{*} q1-q3;
length temp $ 2000;
temp=string;
do i=1 to dim(x);
temp=tranwrd(temp,upcase(vname(x{i})),strip(x{i}));
end;
want=resolve(cats('%sysfunc(',temp,')'));
run;
... View more