<?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 Data Step Do While has worked for years and suddenly churns (recently moved to Snowflake) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907744#M358320</link>
    <description>&lt;P&gt;I use SAS Enterprise Guide 8.3, with Linux server and Windows SAS EG client.&amp;nbsp; We recently moved from Netezza to Snowflake/Azure.&amp;nbsp; This program expands the membership date spans into member months and has worked after we moved to the cloud however 2 months later (no changes to data) the program churns and I have to kill it.&amp;nbsp; Does Snowflake not like the syntax for the do while program? Any ideas why this did work after move to Snowflake and now 1 month later it churns?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;SAMPLE DATA&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;data member_spans;&lt;BR /&gt;infile datalines delimiter= ',';&lt;BR /&gt;input patient_id $ startElig:date9. endElig:date9. transfer;&lt;BR /&gt;format startElig endElig date9. transfer dollar12.2;&lt;BR /&gt;datalines;&lt;BR /&gt;P12345678,01JAN2023,31OCT2023, 4000&lt;BR /&gt;Q23456789,01JAN2023,30JUN2023,461.43&lt;BR /&gt;R34567891,01JAN2023,31MAR2023,544.07&lt;BR /&gt;S45678912,01JAN2023,31AUG2023,3678.69&lt;BR /&gt;S45678912,01SEP2023,31OCT2023,923.46&lt;BR /&gt;T56789123,01OCT2023,31OCT2023,18930&lt;BR /&gt;U67891234,01JAN2023,31MAR2023,-1269.85&lt;BR /&gt;U67891234,01APR2023,31OCT2023,-3019.41&lt;BR /&gt;V78912345,01JAN2023,18JUL2023,-3196.49&lt;BR /&gt;V78912345,19JUL2023,14OCT2023,-1413.52&lt;BR /&gt;V78912345,15OCT2023,31OCT2023,-273.07&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;/*Expand into mms*/&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;data expand_2_mms;&lt;BR /&gt;set Member_Spans ;&lt;BR /&gt;by patient_id startElig endElig ;&lt;BR /&gt;counter=1;&lt;BR /&gt;if transfer ne .;&lt;BR /&gt;do while(startElig &amp;lt;= endElig);&lt;BR /&gt;output;&lt;/P&gt;&lt;P&gt;startElig=intnx('month',startElig,1);&lt;BR /&gt;counter=counter+1;&lt;BR /&gt;if startElig &amp;gt;= endElig then leave;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;format startElig date9.;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Dec 2023 13:59:39 GMT</pubDate>
    <dc:creator>persephone</dc:creator>
    <dc:date>2023-12-13T13:59:39Z</dc:date>
    <item>
      <title>Data Step Do While has worked for years and suddenly churns (recently moved to Snowflake)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907744#M358320</link>
      <description>&lt;P&gt;I use SAS Enterprise Guide 8.3, with Linux server and Windows SAS EG client.&amp;nbsp; We recently moved from Netezza to Snowflake/Azure.&amp;nbsp; This program expands the membership date spans into member months and has worked after we moved to the cloud however 2 months later (no changes to data) the program churns and I have to kill it.&amp;nbsp; Does Snowflake not like the syntax for the do while program? Any ideas why this did work after move to Snowflake and now 1 month later it churns?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;SAMPLE DATA&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;data member_spans;&lt;BR /&gt;infile datalines delimiter= ',';&lt;BR /&gt;input patient_id $ startElig:date9. endElig:date9. transfer;&lt;BR /&gt;format startElig endElig date9. transfer dollar12.2;&lt;BR /&gt;datalines;&lt;BR /&gt;P12345678,01JAN2023,31OCT2023, 4000&lt;BR /&gt;Q23456789,01JAN2023,30JUN2023,461.43&lt;BR /&gt;R34567891,01JAN2023,31MAR2023,544.07&lt;BR /&gt;S45678912,01JAN2023,31AUG2023,3678.69&lt;BR /&gt;S45678912,01SEP2023,31OCT2023,923.46&lt;BR /&gt;T56789123,01OCT2023,31OCT2023,18930&lt;BR /&gt;U67891234,01JAN2023,31MAR2023,-1269.85&lt;BR /&gt;U67891234,01APR2023,31OCT2023,-3019.41&lt;BR /&gt;V78912345,01JAN2023,18JUL2023,-3196.49&lt;BR /&gt;V78912345,19JUL2023,14OCT2023,-1413.52&lt;BR /&gt;V78912345,15OCT2023,31OCT2023,-273.07&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;/*Expand into mms*/&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;data expand_2_mms;&lt;BR /&gt;set Member_Spans ;&lt;BR /&gt;by patient_id startElig endElig ;&lt;BR /&gt;counter=1;&lt;BR /&gt;if transfer ne .;&lt;BR /&gt;do while(startElig &amp;lt;= endElig);&lt;BR /&gt;output;&lt;/P&gt;&lt;P&gt;startElig=intnx('month',startElig,1);&lt;BR /&gt;counter=counter+1;&lt;BR /&gt;if startElig &amp;gt;= endElig then leave;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;format startElig date9.;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 13:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907744#M358320</guid>
      <dc:creator>persephone</dc:creator>
      <dc:date>2023-12-13T13:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Do While has worked for years and suddenly churns (recently moved to Snowflake)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907792#M358332</link>
      <description>&lt;P&gt;You don't show any connection to Snowflake so I am &lt;STRONG&gt;guessing&lt;/STRONG&gt; that perhaps Snowflake stores dates differently than Netezza and your connection with Snowflake isn't doing the date conversion "correctly".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you could share exactly how you connect to Snowflake and the code submitted with some LOG entry to provide more details that someone familiar with Snowflake can diagnose.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 15:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907792#M358332</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-13T15:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Do While has worked for years and suddenly churns (recently moved to Snowflake)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907816#M358338</link>
      <description>&lt;P&gt;DATA step code does not run in Snowflake, so the techniques you use for DATA step processing aren't an issue. Here are some considerations:&lt;/P&gt;
&lt;P&gt;1. You really shouldn't use a subsetting IF statement when reading database data in SAS if you can get the same result using a WHERE statement. To improve the efficiency of your code, replace:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if transfer ne .;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where transfer is not null;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will minimize the amount of data pulled into SAS from Snowflake for processing.&lt;/P&gt;
&lt;P&gt;2. Is it possible you have some bad records in your data where the&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;startElig&lt;/STRONG&gt;&amp;nbsp;value is missing? If so, your code will go into an infinite loop. &lt;BR /&gt;You can avoid this situation by adding code to avoid reading records with missing&amp;nbsp;&lt;STRONG&gt;startElig&lt;/STRONG&gt;&amp;nbsp;values:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where transfer is not null and startElig is not null;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;or add code to impute a value for a missing&amp;nbsp;&lt;STRONG&gt;startElig&lt;/STRONG&gt;&amp;nbsp;before entering the loop:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;startElig=colaesce(startElig, endElig-1);
do while(startElig &amp;lt;= endElig);
   *... more statement s ...;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Is the dataset you are reading growing in size? If so, expect longer run times as the size of the data grows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 16:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907816#M358338</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2023-12-13T16:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Do While has worked for years and suddenly churns (recently moved to Snowflake)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907890#M358355</link>
      <description>&lt;P&gt;Can you share the log from running the step (and after waiting a while, killing it)?&amp;nbsp; There should be some helpful clues there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To detect the potential infinite loop problem, you could add something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;counter=1;
do while(startElig &amp;lt;= endElig);
  output;

  startElig=intnx('month',startElig,1);
  if startElig &amp;gt;= endElig then leave;
  counter=counter+1;
  if counter  &amp;gt; 1000 then do;
    put "ERROR: infinite loop!" patientID= startElig= endElig=;
    leave;
  end;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I agree with SAS Jedi's suggestion that a missing value for StartElig would be one easy way for your current code to trigger an infinite loop.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 19:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907890#M358355</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-12-13T19:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Do While has worked for years and suddenly churns (recently moved to Snowflake)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907947#M358362</link>
      <description>&lt;P&gt;Thanks Jedi!&amp;nbsp; You are spot on.&amp;nbsp;&lt;BR /&gt;I do a validation of the data prior to this data step so I knew that wasn't the issue.&lt;BR /&gt;I implemented the 'where variables are not nulll) for both transfer and startElig and it ran successfully in .26 seconds.&lt;/P&gt;&lt;P&gt;Very much appreciate your prompt reply and assistance!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 21:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907947#M358362</guid>
      <dc:creator>persephone</dc:creator>
      <dc:date>2023-12-13T21:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Do While has worked for years and suddenly churns (recently moved to Snowflake)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907949#M358364</link>
      <description>&lt;P&gt;Thanks for your prompt response and suggestion to identify an infinite loop Quentin.&lt;BR /&gt;Will definitely use this in the future!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 21:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Do-While-has-worked-for-years-and-suddenly-churns/m-p/907949#M358364</guid>
      <dc:creator>persephone</dc:creator>
      <dc:date>2023-12-13T21:23:59Z</dc:date>
    </item>
  </channel>
</rss>

