Hello,
I have a dataset (Data1) like as below. The variable string indicates how to sum up Q1 ~ Q3.
ID Q1 Q2 Q3 string
1 1 3 1 sum(Q1, Q3)
2 3 2 2 sum(Q1, Q2, Q3)
3 2 1 4 sum(Q2, Q3)
Now I would like to create a new numerical variable Score which is sumed as string text:
ID Q1 Q2 Q3 string Score
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
My code:
Data _null_;
set Data1;
call symput('n' !! strip(_n_), string);
call symput('total' , _n_);
Run;
%macro test;
Data compute;
set Data1;
%Do i = 1 %to &total;
Score = &&n&i;
%End;
Run;
%mend;
%test;
But a error message keeps saying "Syntax error". Does anyone know what the problem is? How to modify my code? Thanks.
ps.The log window is attached below.
... View more