title: sas, simplest task: assign input value to a global variable
body: <p>A bit confused how to assign an input value to a variable I can pass further to macros or to work with outside the &quot;data&quot; statement, such as a global variable.</p>
  <p>This is the code:</p>
  <pre><code>&amp;let gvar=;
  
  %macro mm ( in1 );
  %put &amp;in1;
  %mend;
  
  data _null_;
  infile stdin;
  input resp $ ;
  /* This works, displaying the value user has entered */
  put resp;
  /* This passes the word &quot;resp&quot; instead of a received value */
  %mm (resp);
  /* This passes a blank value instead of a received value */
  %mm (&amp;resp);
  /* This also assigns the word &quot;resp&quot; instead of a received value */
  %let gvar=resp;
  stop;
  run;
  
  %put &amp;gvar;
  </code></pre>
  <p>Output:</p>
  <pre><code>$ Value11
  
  Value11
  resp
  WARNING: Apparent symbolic reference RESP not resolved.
  resp 
  </code></pre>
  <p>Per Tom's suggestion, this is the working piece, however, for some reason two lines are read from stdin, instead of 1.</p>
  <pre><code>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;
  </code></pre>