title: why does the MAX function strip the SAS variable format in proc sql?
body: <p>Consider the following:</p>
  
  <pre><code>data; 
  format x datetime19.;
  x=datetime();
  flag='FIRST';
  do x=datetime() to x+10 by 1;
      output;
      flag='';
  end;
  proc sql noprint;
  select x into : test1 from &amp;syslast where flag='FIRST';
  select max(x) into: test2 from &amp;syslast;
  %put now we see that &amp;test1 is in a different format to &amp;test2;
  
  data _null_;  set;
  put x=; /* formatted */
  call symput('test3',x);
  call symput('test4',max(x,sum(x+1000)));
  stop;
  run;
  %put The data step is more consistent - &amp;test3 = &amp;test4;
  </code></pre>
  
  <p>Seems inconsistent to me.  Why does proc sql retain the format in this case?  Is this behaviour documented?</p>