I'm glad that you found the solution. But note that this will keep only one value in the macro variable when you have multiple values.
Check this two approaches where there are multiple values to be accounted.
proc sql noprint;
select name into: Name
from sashelp.class;
quit;
proc sql;
select * from sashelp.class
where name="&Name"
;
Quit;
proc sql noprint;
select quote(strip(name)) into:Name separated by ','
from sashelp.class;
quit;
proc sql;
select * from sashelp.class
where name in (&name)
;
Quit;
Thanks,
Suryakiran