<?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: Proc SQL macro &amp;quot;skipping&amp;quot; updates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83482#M18027</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems a bit unintuitive in SAS to update row by row like that as well. I've seen that done using cursors in SQL, but not in SAS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like straight join by row, and that A and B are set to the same thing?&amp;nbsp; I'm not sure if you simplified the code to post it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Mar 2013 18:45:12 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-03-20T18:45:12Z</dc:date>
    <item>
      <title>Proc SQL macro "skipping" updates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83479#M18024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written some code to update a table with various values from another table, however, SAS seems to randomly skip updating rows, even when the conditions at satisfied. I have noticed that if I restart SAS (close and re-open) the problem seems to be alleviated to some degree, but there will still missing values at times. I would say that this happens about 90% of the time I try and run the code. Furthermore, each time I run the code, (even with the same input data) the rows that don't get updated are different each time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;%if &amp;amp;i=1 %then %do;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;proc sql feedback;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;alter table l.raw_%sysfunc(date(),date7.)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;add A num format best32.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;add B num format best32.;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;update l.raw_%sysfunc(date(),date7.) t1 &lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;set A = (select ppg_total_&amp;amp;rpi2._a from l.raw_%sysfunc(date(),date7.)_copy where monotonic() = &amp;amp;i) where monotonic() = &amp;amp;i;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;update l.raw_%sysfunc(date(),date7.) t1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;set B = (select ppg_allow_total_&amp;amp;rpi2._a from l.raw_%sysfunc(date(),date7.)_copy where monotonic() = &amp;amp;i) where monotonic() = &amp;amp;i;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;quit; &lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;%end;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;%else %do;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;proc sql;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;update l.raw_%sysfunc(date(),date7.) t1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;set A = (select ppg_total_&amp;amp;rpi2._a from l.raw_%sysfunc(date(),date7.)_copy where monotonic() = &amp;amp;i) where monotonic() = &amp;amp;i;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;update l.raw_%sysfunc(date(),date7.) t1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;set B = (select ppg_allow_total_&amp;amp;rpi2._a from l.raw_%sysfunc(date(),date7.)_copy where monotonic() = &amp;amp;i) where monotonic() = &amp;amp;i;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;quit; &lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;%end;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 16:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83479#M18024</guid>
      <dc:creator>anlynch</dc:creator>
      <dc:date>2013-03-20T16:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL macro "skipping" updates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83480#M18025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't tell if this is the problem or not, but I believe that SAS considers the MONOTONIC function to be an undocumented, unsupported feature.&amp;nbsp; It could be a source of problems.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 17:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83480#M18025</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-03-20T17:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL macro "skipping" updates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83481#M18026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yea, i had a feeling that monotonic might have something to do with it. i am trying to think of a solution to work around using monotonic. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 17:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83481#M18026</guid>
      <dc:creator>anlynch</dc:creator>
      <dc:date>2013-03-20T17:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL macro "skipping" updates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83482#M18027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems a bit unintuitive in SAS to update row by row like that as well. I've seen that done using cursors in SQL, but not in SAS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like straight join by row, and that A and B are set to the same thing?&amp;nbsp; I'm not sure if you simplified the code to post it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 18:45:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83482#M18027</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-20T18:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL macro "skipping" updates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83483#M18028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A and B are different variables, but the way in which they are retrieved are the same (one is pgg_total and one is ppg_allow).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the problem i am running into is getting sas to update only one row at a time... which is why i have two monotonic() constraints. the first retrieves the value from the table, and then the second only updates one row at a time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: i am guessing i can figure out a better way to write this, without using monotonic() like this, but its intriguing to me that SAS evaluates it differently each time the code is executed. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 18:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83483#M18028</guid>
      <dc:creator>anlynch</dc:creator>
      <dc:date>2013-03-20T18:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL macro "skipping" updates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83484#M18029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not write your updating process in a DATA step where you have full row-by-row control and don't require undocumented features?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 18:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83484#M18029</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2013-03-20T18:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL macro "skipping" updates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83485#M18030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tend to use sql as a crutch... more than I should. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyhow, I still kept the meat of the sql there, but instead of using monotonic i used a data step to create a macro variable to keep the constraints. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...and before I wrote this post, I didn't realize that monotonic was unsupported. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 19:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83485#M18030</guid>
      <dc:creator>anlynch</dc:creator>
      <dc:date>2013-03-20T19:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL macro "skipping" updates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83486#M18031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Understandible if you come from an SQL background, but SAS DATA step processing goes way beyond what you can do in SQL with the bonus of row-by-row control.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've done SQL stored procedures with cursors to get row control but its way more complicated than DATA steps &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 22:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83486#M18031</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2013-03-20T22:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL macro "skipping" updates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83487#M18032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you explain in non code what that program is trying to do?&lt;/P&gt;&lt;P&gt;I wouldn't normally use an "ALTER TABLE" statement in SAS.&amp;nbsp; To add a column to a table would require SAS to totally recreate the table. So at that point why not just use a data step or an SQL create table statement to make the table you want?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 00:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-macro-quot-skipping-quot-updates/m-p/83487#M18032</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-21T00:51:32Z</dc:date>
    </item>
  </channel>
</rss>

