<?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 for loop hangs exactly at 27th cycle in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/569137#M449</link>
    <description>&lt;P&gt;Ok, the best next step I can think of is to try to get some additional logging, from when it hangs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you submit from the command line, I want you to specify the following command line option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;-LOGPARM "WRITE=IMMEDIATE"&lt;/PRE&gt;
&lt;P&gt;In your SAS program, let's also increase the log verbosity by adding the following line of code at the top of the program&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;OPTIONS MLOGIC MLOGICNEST MPRINT MPRINTNEST MSGLEVEL=I;&lt;/PRE&gt;
&lt;P&gt;In your HTTP Procedure call you use the debug statement. Let's also increase the level&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC HTTP [...];
  DEBUG LEVEL = 3;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This all will produce a significantly larger log file, but specifically, what we care about most is if any additional log information is produced when the loop gets 'stuck' and the process appears to hang.&amp;nbsp; As well as any potential logging produced when you, I assume, terminate the process.&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jun 2019 15:40:57 GMT</pubDate>
    <dc:creator>FriedEgg</dc:creator>
    <dc:date>2019-06-26T15:40:57Z</dc:date>
    <item>
      <title>Macro for loop hangs exactly at 27th cycle</title>
      <link>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568706#M426</link>
      <description>&lt;P&gt;I have this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Mock dataset */
data DaCensire;
    do i=1 to 4000;
        id=cats('z',put(rand('integer',1,999999),z6.));
        Newgroup='XXX';
        output;
    end;
run;

data DaCensire;
    set DaCensire;
    call symputx('NCensimenti',_N_);
    call symputx(cats('censimento',_N_), id);
    call symputx(cats('gruppo',_N_), Newgroup);
run;


%macro assegnazioneGruppo;
    
    %do h=1 %to &amp;amp;NCensimenti;
        %put Inserisco utenza &amp;amp;h/&amp;amp;NCensimenti e &amp;amp;&amp;amp;censimento&amp;amp;h nel gruppo &amp;amp;&amp;amp;gruppo&amp;amp;h;
            proc http url="https://xxx/identities/groups/&amp;amp;&amp;amp;gruppo&amp;amp;h/userMembers/&amp;amp;&amp;amp;censimento&amp;amp;h"
                method="PUT"
                OAUTH_BEARER=SAS_SERVICES;
                debug level = 1;
            run;
        %put Fine inserimento utenza &amp;amp;h/&amp;amp;NCensimenti e &amp;amp;&amp;amp;censimento&amp;amp;h nel gruppo &amp;amp;&amp;amp;gruppo&amp;amp;h;
    %end;

%mend;

%assegnazioneGruppo;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macrovar NCensimenti is about 4.000.&lt;/P&gt;
&lt;P&gt;This code works exactly fine, but a really weird thing happens: the 26th iteration runs to the end (I see in the log the last %put), but the 27th iteration never starts (I don't see the first %put) and the code freezes forever.&lt;/P&gt;
&lt;P&gt;I taught there may be something with the 27th value, but when I run the whole code again the list is randomized, so the 27th value changes every time but still, exactly at the 27th iteration, it never starts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What may be happening?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 12:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568706#M426</guid>
      <dc:creator>Edoedoedo</dc:creator>
      <dc:date>2019-06-25T12:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for loop hangs exactly at 27th cycle</title>
      <link>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568713#M427</link>
      <description>&lt;P&gt;Can you provide some logic to generate dummy data that represents the data on 'DaCensire'? That would be helpful in understanding the logic better. Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 11:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568713#M427</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-06-25T11:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for loop hangs exactly at 27th cycle</title>
      <link>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568726#M428</link>
      <description>Sure, I've just edited the code with a mock dataset. Just to clarify, the dataset 'DaCensire' contains a list of user id and a SASViya group they should belong to. Then, with the macro %assegnazioneGruppo, an http call is executed against Viya API to add the i-th user to its group.</description>
      <pubDate>Tue, 25 Jun 2019 12:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568726#M428</guid>
      <dc:creator>Edoedoedo</dc:creator>
      <dc:date>2019-06-25T12:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for loop hangs exactly at 27th cycle</title>
      <link>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568776#M429</link>
      <description>&lt;P&gt;When something regarding a web site or service quits working at a fixed number of iterations regardless of the data content I start to suspect some sort of setting at the web site. You might be triggering a defense against denial of service attacks, web crawlers or any number of things hitting the same site numerous times in a short period of time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did not attach any LOG to inspect.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 14:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568776#M429</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-25T14:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for loop hangs exactly at 27th cycle</title>
      <link>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568788#M430</link>
      <description>&lt;P&gt;Because there is nothing to inspect in the log, it just freezes... The web site is the standard SASViya REST APIs for handling identities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I add here the log from the 25th to the end of the log. I've added some red marks (*) to comment that line after:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;.......
Inserisco utenza 25/2083 e z123456 nel gruppo XXX &lt;FONT color="#FF0000"&gt;(*1)&lt;/FONT&gt;

&amp;gt; PUT /identities/groups/XXX/userMembers/z123456 HTTP/1.1

&amp;gt; User-Agent: SAS/9

&amp;gt; Host: sasviya

&amp;gt; Accept: */*

&amp;gt; Authorization: Bearer

&amp;gt; Connection: Keep-Alive

&amp;gt; Content-Length: 0

&amp;gt; Content-Type: application/octet-stream

&amp;gt;

&amp;lt; HTTP/1.1 201

&amp;lt; Cache-Control: no-cache, no-store, max-age=0, must-revalidate

&amp;lt; Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' *.sas.com blob:
data:; style-src 'self' 'unsafe-inline'; child-src 'self' blob: data: mailto:;

&amp;lt; Date: Tue, 25 Jun 2019 11:35:23 GMT

&amp;lt; Expires: 0

&amp;lt; Pragma: no-cache

&amp;lt; Server: Apache/2.4

&amp;lt; Strict-Transport-Security: max-age=31536000 ; includeSubDomains

&amp;lt; Vary: User-Agent

&amp;lt; X-Content-Type-Options: nosniff

&amp;lt; X-Frame-Options: SAMEORIGIN

&amp;lt; X-XSS-Protection: 1; mode=block

&amp;lt; Content-Length: 0

&amp;lt; Connection: keep-alive

&amp;lt;

NOTE: PROCEDURE HTTP ha utilizzato (tempo totale di elaborazione): &lt;FONT color="#FF0000"&gt;(*2)&lt;/FONT&gt;

      real time           0.21 seconds
      cpu time            0.02 seconds


Fine inserimento utenza 25/2083 e z123456 nel gruppo XXX &lt;FONT color="#FF0000"&gt;(*3)&lt;/FONT&gt;

Inserisco utenza 26/2083 e z123457 nel gruppo XXX &lt;FONT color="#FF0000"&gt;(*4)&lt;/FONT&gt;

&amp;gt; PUT /identities/groups/XXX/userMembers/z123457 HTTP/1.1

&amp;gt; User-Agent: SAS/9

&amp;gt; Host: sasviya

&amp;gt; Accept: */*

&amp;gt; Authorization: Bearer

&amp;gt; Connection: Keep-Alive

&amp;gt; Content-Length: 0

&amp;gt; Content-Type: application/octet-stream

&amp;gt;

&amp;lt; HTTP/1.1 201

&amp;lt; Cache-Control: no-cache, no-store, max-age=0, must-revalidate

&amp;lt; Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' *.sas.com blob:
data:; style-src 'self' 'unsafe-inline'; child-src 'self' blob: data: mailto:;

&amp;lt; Date: Tue, 25 Jun 2019 11:35:33 GMT

&amp;lt; Expires: 0

&amp;lt; Pragma: no-cache

&amp;lt; Server: Apache/2.4

&amp;lt; Strict-Transport-Security: max-age=31536000 ; includeSubDomains

&amp;lt; Vary: User-Agent

&amp;lt; X-Content-Type-Options: nosniff

&amp;lt; X-Frame-Options: SAMEORIGIN

&amp;lt; X-XSS-Protection: 1; mode=block

&amp;lt; Content-Length: 0

&amp;lt; Connection: keep-alive

&amp;lt;

NOTE: PROCEDURE HTTP ha utilizzato (tempo totale di elaborazione): &lt;FONT color="#FF0000"&gt;(*5)&lt;/FONT&gt;
      real time           0.04 seconds
      cpu time            0.00 seconds


Fine inserimento utenza 26/2083 e z123457 nel gruppo XXX &lt;FONT color="#FF0000"&gt;(*6)
(*7)&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Comments:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;It corresponds to the very first %put of the cycle, so the 24th iteration has just started&lt;/LI&gt;
&lt;LI&gt;The proc http called with the 24th user ended and is successful&lt;/LI&gt;
&lt;LI&gt;It corresponds to the very last %put of the cycle, so the 24th iteration has just completely ended&lt;/LI&gt;
&lt;LI&gt;It corresponds to the very first %put of the cycle, so the 25th iteration has just started&lt;/LI&gt;
&lt;LI&gt;The proc http called with the 25th user ended and is successful&lt;/LI&gt;
&lt;LI&gt;It corresponds to the very last %put of the cycle, so the 25th iteration has just completely ended&lt;/LI&gt;
&lt;LI&gt;!!! It doesn't even start the next cycle with the first %put! If the problem was the proc http, I would expect that at least the first %put of the 27th iteration would have been printed! But it just stops doing anything, the code remains running forever, and nothing else happens.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 25 Jun 2019 14:20:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568788#M430</guid>
      <dc:creator>Edoedoedo</dc:creator>
      <dc:date>2019-06-25T14:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for loop hangs exactly at 27th cycle</title>
      <link>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568850#M431</link>
      <description>&lt;P&gt;What interface are you using to submit the SAS code?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 16:05:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/568850#M431</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2019-06-25T16:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for loop hangs exactly at 27th cycle</title>
      <link>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/569023#M432</link>
      <description>&lt;P&gt;At first with Sas Studio V. Then directly with a scheduled Job (so without an interface, like command line) redirecting the log to a file.&lt;/P&gt;
&lt;P&gt;In both the cases the behavior is the same as I described above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 09:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/569023#M432</guid>
      <dc:creator>Edoedoedo</dc:creator>
      <dc:date>2019-06-26T09:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for loop hangs exactly at 27th cycle</title>
      <link>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/569137#M449</link>
      <description>&lt;P&gt;Ok, the best next step I can think of is to try to get some additional logging, from when it hangs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you submit from the command line, I want you to specify the following command line option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;-LOGPARM "WRITE=IMMEDIATE"&lt;/PRE&gt;
&lt;P&gt;In your SAS program, let's also increase the log verbosity by adding the following line of code at the top of the program&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;OPTIONS MLOGIC MLOGICNEST MPRINT MPRINTNEST MSGLEVEL=I;&lt;/PRE&gt;
&lt;P&gt;In your HTTP Procedure call you use the debug statement. Let's also increase the level&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC HTTP [...];
  DEBUG LEVEL = 3;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This all will produce a significantly larger log file, but specifically, what we care about most is if any additional log information is produced when the loop gets 'stuck' and the process appears to hang.&amp;nbsp; As well as any potential logging produced when you, I assume, terminate the process.&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 15:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/569137#M449</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2019-06-26T15:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for loop hangs exactly at 27th cycle</title>
      <link>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/569371#M450</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;I'm having difficulties setting&lt;/P&gt;
&lt;PRE&gt;-LOGPARM "WRITE=IMMEDIATE"&lt;/PRE&gt;
&lt;P&gt;because the program is launched as a job in the SASJobExecution (so it's like a batch but there isn't a real command line where I can put parameters) and inside I redirect the log to a file with proc printto. How to set the LOGPARM using&amp;nbsp;SASJobExecution?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 09:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Macro-for-loop-hangs-exactly-at-27th-cycle/m-p/569371#M450</guid>
      <dc:creator>Edoedoedo</dc:creator>
      <dc:date>2019-06-27T09:42:02Z</dc:date>
    </item>
  </channel>
</rss>

