The important point to remember is that use of SAS macro must result in syntactically and logically correct SAS code. Your example:
%let greet = Hello my name is Sam;
data hello;
greet = %scan("&greet",1, " ");
run;
Will resolve to this SAS code:
data hello;
greet = hello;
run;
HELLO doesn't exist as a variable so GREET is set to a missing value.
Since you want to assign the value "Hello" to GREET, all you need to do is wrap your %SCAN in double quotes:
data hello;
greet = "%scan("&greet",1, " ")";
run;
... View more