You can't run proc sql inside a data step, think about it.
2 ways to do what you want:
Either look up the data some other way (no need to call a macro to look up data), or if you need to do more complex things in your macro, it has to be pure macro language for the data step to run it immediately.
This does both:
[pre]
data look_up(index=(ID));
input id D1 $ D2 $ D3 $;
datalines;
1 A B C
2 D E F
3 G H I
4 J K L
5 M N O
6 P Q R
7 S T U
8 V W X
9 Y Z A
run;
%macro temp(number);
%global var1 var2 var3;
%let dsid=%sysfunc(open(look_up(where=(ID = &number))));
%let rc=%sysfunc(fetch(&dsid));
%let var1=%sysfunc(getvarc(&dsid,%sysfunc(varnum(&dsid,D1))));
%let var2=%sysfunc(getvarc(&dsid,%sysfunc(varnum(&dsid,D2))));
%let var3=%sysfunc(getvarc(&dsid,%sysfunc(varnum(&dsid,D3))));
%let rc=%sysfunc(close(&dsid));
%mend;
%let id = 2;
data TEST;
call execute ('%temp('||put(&id,3.)||')'); *get values from macro;
T1 = symget('var1');
T2 = symget('var2');
T3 = symget('var3');
output;
ID = &id+1;
set look_up key=ID; *get values from look-up key
T1 = D1;
T2 = D2;
T3 = D3;
output;
stop;
run;[/pre]