A bit confused how to assign an input value to a variable I can pass further to macros or to work with outside the "data" statement, such as a global variable.
This is the code:
&let gvar=;
%macro mm ( in1 );
%put &in1;
%mend;
data _null_;
infile stdin;
input resp $ ;
/* This works, displaying the value user has entered */
put resp;
/* This passes the word "resp" instead of a received value */
%mm (resp);
/* This passes a blank value instead of a received value */
%mm (&resp);
/* This also assigns the word "resp" instead of a received value */
%let gvar=resp;
stop;
run;
%put &gvar;
Output:
$ Value11
Value11
resp
WARNING: Apparent symbolic reference RESP not resolved.
resp
Per Tom's suggestion, this is the working piece, however, for some reason two lines are read from stdin, instead of 1.
data _null_;
infile stdin obs=1;
input resp $ ;
call symputx('gvar',resp,'g');
/* I do have to put/uncomment the stop instruction below to force a single-line input */
*stop;
run;
Let's start with what you say works and add code to create a macro variable from the value in the data step. Use the CALL SYMPUTX() function. To force the macro variable into the global symbol table (even if you are running the data step inside of a macro scope) use the optional third parameter.
data _null_;
infile stdin obs=1;
input resp $ ;
call symputx('gvar',resp,'g');
run;