<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro Loop Problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-Problem/m-p/916972#M361193</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/434755"&gt;@LuisDalmasso&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the reason for the error message is the missing semicolon after the first QUIT statement.&lt;/P&gt;</description>
    <pubDate>Tue, 20 Feb 2024 13:24:39 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2024-02-20T13:24:39Z</dc:date>
    <item>
      <title>Macro Loop Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-Problem/m-p/916959#M361185</link>
      <description>&lt;P&gt;Hello, when running this code I get an error and I can't detect the problem. It also stays running indefinitely.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is the code&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%global Error_Conexion_paso1;

/* Acceso a los datos para DMPRD - libreria DM SSGPMBI  */ 
LIBNAME DMPRD ORACLE  UPDATE_LOCK_TYPE=TABLE  OR_UPD_NOWHERE=NO  PATH="SASSTPRD.world"  SCHEMA=SAS_DM  AUTHDOMAIN="ORA_SAS_DM_Auth" ;
/* Acceso a los datos para CAS_DMPRD  */ 
LIBNAME CASDMPRD CAS  CASLIB=DMPRD  PORT=5570  SERVER="sasva-root.gcba.gob.ar" ;

%global sessref_option;
%let sessref_option=%sysfunc(getoption(SESSREF));
%let DAY = %sysfunc(today(),DDMMYYn8.);
%let HH = %sysfunc(hour(%sysfunc(datetime()) ) );
%let MM = %sysfunc(minute(%sysfunc(datetime()) ) );

%put &amp;amp;=DAY;
%put &amp;amp;=HH;
%put &amp;amp;=MM;

%global SessionName;
%LET SessionName = CAS_&amp;amp;DAY._&amp;amp;HH._&amp;amp;MM.;
%put &amp;amp;=SessionName;
%macro test;
proc sql ;

SELECT CAS_NAME, FECHA, (MONOTONIC()+500) as ID_CONTROL_CAS_CARGA length = 8 
  into :CASN1 - :CASN50
  ,:FE1 - :FE150
  ,:ID1 - :ID150
FROM  DMPRD.ETL_CONTROL_CAS_CARGA_RCE 
WHERE CAS_NAME NOT LIKE '%TABLON%'
AND FECHA = DHMS(TODAY(),0,0,0)
AND CAS_NAME &amp;lt;&amp;gt;  'RCE_SOLICITUD_EN_TRAMITE' 
AND TABLAS_CARGADAS = 1   
AND FECHA_FIN_CARGA_CAS is null 
;
QUIT
%let nobs=&amp;amp;sqlobs;
%do i=1 %to &amp;amp;nobs ;

%let Error_Conexion_paso1 = &amp;amp;syserrortext.;
%let FECHA_INICIO=%sysfunc(datetime());
%put &amp;amp;=(&amp;amp;&amp;amp;ID&amp;amp;i.);
%put &amp;amp;="&amp;amp;&amp;amp;CASN&amp;amp;i.";
%put &amp;amp;=&amp;amp;FECHA_INICIO.;

PROC SQL;
	UPDATE DMPRD.ETL_CONTROL_CAS_CARGA_RCE SET ID_CONTROL_CAS_CARGA=&amp;amp;&amp;amp;ID&amp;amp;i. where CAS_NAME ="&amp;amp;&amp;amp;CASN&amp;amp;i." and FECHA = DHMS(TODAY(),0,0,0) ;
quit;
%let FECHA_FIN=%sysfunc(datetime());
proc sql;
	UPDATE DMPRD.ETL_CONTROL_CAS_CARGA_RCE SET CARGA_CAS_EN_CURSO=0 where ID_CONTROL_CAS_CARGA=&amp;amp;&amp;amp;ID&amp;amp;i. and FECHA = DHMS(TODAY(),0,0,0) and &amp;amp;syserr. = 0;
quit;
%put &amp;amp;=syserr;
%end;
%mend;
%test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The error is when you run the macro on the first UPDATE and then it stays running indefinitely&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;124 %mend;&lt;BR /&gt;125 &lt;BR /&gt;126 %test;&lt;BR /&gt;NOTE: El operador "&amp;lt;&amp;gt;" se interpreta como "no igual".&lt;BR /&gt;&amp;amp;=(501)&lt;BR /&gt;&amp;amp;="VW_RCE_ADOPCIONES"&lt;BR /&gt;&amp;amp;=2024037910.85303&lt;BR /&gt;NOTE: The PROCEDURE SQL printed page 1.&lt;BR /&gt;NOTE: PROCEDURE SQL ha utilizado (Tiempo de proceso total):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;
&lt;P&gt;NOTE: Line generated by the invoked macro "TEST".&lt;BR /&gt;126 UPDATE DMPRD.ETL_CONTROL_CAS_CARGA_RCE SET ID_CONTROL_CAS_CARGA=&amp;amp;&amp;amp;ID&amp;amp;i. where CAS_NAME ="&amp;amp;&amp;amp;CASN&amp;amp;i." and&lt;BR /&gt;______&lt;BR /&gt;180&lt;BR /&gt;126 ! FECHA = DHMS(TODAY(),0,0,0) ; quit;&lt;/P&gt;
&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;From now, thank you for you help&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 12:14:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-Problem/m-p/916959#M361185</guid>
      <dc:creator>LuisDalmasso</dc:creator>
      <dc:date>2024-02-20T12:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-Problem/m-p/916961#M361186</link>
      <description>&lt;P&gt;Can you turn on options MPRINT, then run the macro and post the full log?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 12:33:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-Problem/m-p/916961#M361186</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-02-20T12:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-Problem/m-p/916963#M361187</link>
      <description>&lt;P&gt;When you have a macro that produces an error in the log, please turn on the macro debugging option by running this line of code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then run the macro again, and show us the log for the PROC SQL that has the error (not just the error messages, we need to see the code as it appears in the log as well, from PROC SQL down to the last note after the PROC). Please copy the log as text and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon. Please do this from now on whenever you have an error.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1699900743276.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89703i797B759183DE7484/image-size/large?v=v2&amp;amp;px=999" role="button" title="PaigeMiller_0-1699900743276.png" alt="PaigeMiller_0-1699900743276.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 12:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-Problem/m-p/916963#M361187</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-20T12:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-Problem/m-p/916972#M361193</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/434755"&gt;@LuisDalmasso&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the reason for the error message is the missing semicolon after the first QUIT statement.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 13:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-Problem/m-p/916972#M361193</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-02-20T13:24:39Z</dc:date>
    </item>
  </channel>
</rss>

