title: SAS DI (Data Integration): Inserting a Data in an existing Table
body: <p>I have a program in SAS 9.3 (please refer below) that I need to do in SAS Data Integration Studio:</p>
  
  <pre><code>%macro sqlloop;
    Proc SQL;
     Select distinct(DATE) into :raw_date from RAW;
    Quit;
    %DO k= %sysevalf("&amp;raw_date"d) %TO  %eval(%sysfunc(today())-1);
     PROC SQL;
      insert into CONSOLIDATED (BRANCH_CD, RC_NAME, DATE)
      select BRANCH_CD, RC_NAME, &amp;k.
      from RAW;
     QUIT;
    %END;
  %mend;
  %sqlloop;
  </code></pre>
  
  <p>To do this in SAS Data Integration Studio, I did the step and the code inside the "User Written" below:</p>
  
  <blockquote>
    <p>RAW ------> User Written -----> Table Loader -----> Consolidated</p>
  </blockquote>
  
  <pre><code> %let output= &amp;_output;
   %let MySYSLast= &amp;SYSLast;
   %macro sqlloop;
    Proc SQL;
     Select distinct(DATE) into :raw_date from &amp;MySYSLast;
    Quit;
    %DO k= %sysevalf("&amp;raw_date"d) %TO  %eval(%sysfunc(today())-1);
     PROC SQL;
      insert into &amp;output (BRANCH_CD, RC_NAME, DATE)
      select BRANCH_CD, RC_NAME, &amp;k.
      from &amp;MySYSLast;
     QUIT;
    %END;
   %mend;
   %sqlloop;
  </code></pre>
  
  <p>However, I am receiving an error in running this in SAS DI. May I know how to do this properly in SAS DI? </p>