title: Insert and update using proc sql simultaneously in SAS
body: <p>I am importing a file using proc import</p>
  
  <pre><code>proc import datafile="/opt/Export_d.csv" replace
  out=work.export_data; run;
  </code></pre>
  
  <p>THEN I SELECTED 2 VARIABLES FROM EXPORTED TABLE HAVING SOME CONDITION
  proc SQL;</p>
  
  <pre><code>create table work.login2
  as select ' SURVEY_ID'n, TIME format=datetime20.,' USERNAME'n
  from work.export_data
  having TIME=max(TIME) and ' USERNAME'="sasdemo";
  quit;
  </code></pre>
  
  <p>then i created a macro for survey_id because i have to update a value with the Survey_id reference in different table shown in below code:</p>
  
  <pre><code>proc SQL;
  select max(' SURVEY_ID'n) into: sid from work.login2;
  quit;
  </code></pre>
  
  <p>now if the ID is blank then i don't have to insert anything but if we have survey_id we have update few columns in a table using below code which is not happening.</p>
  
  <pre><code>proc SQL;
  case when ' SURVEY_ID'n is not null then update table_name set SAS_TRACKING_CODE="&amp;Trackingcode."
  where SURVEY_ID=&amp;sid.
  else end;
  quit;
  </code></pre>