<?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: Update HUGE indexed table with SQL (in SPD library) seems not to run at all. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941859#M369450</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18088"&gt;@Longimanus&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Aha ... so I need the full monty if I want to do it that way.&amp;nbsp; So you are saying that running with a Datastep would not help me a bit. I still cannot use the view. Right?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not to change values in a view.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Performance issues with large data sets I often suggest talking to the data base manager or other people involved in managing the data. It may be that you can provide them the data from SAS and have them update the data set. Or use "pass through" code to call external database management tools to work with that. I don't work with SPD so I'm not sure if this is an option.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Aug 2024 21:08:02 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-08-29T21:08:02Z</dc:date>
    <item>
      <title>Update HUGE indexed table with SQL (in SPD library) seems not to run at all.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941838#M369445</link>
      <description>&lt;P&gt;Hi folks! I need help!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a problem not even ChatGTP can solve.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt; Sure the suggested solutions look pretty good but there is always something wrong when I try to run it.&amp;nbsp; I tried to change and "tell" ChatGTP something is wrong, and then it starts: You are completely right. I will send you the correct code. Well ... that also doesn't work. At some point the BOT gets it ... but not yet.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My problem:&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":flushed_face:"&gt;😳&lt;/span&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I need to update one variable &lt;STRONG&gt;altered_dttm&lt;/STRONG&gt; in table &lt;STRONG&gt;TABLE_1&lt;/STRONG&gt; which is &lt;FONT color="#339966"&gt;&lt;U&gt;SO HUGE&lt;/U&gt;&lt;/FONT&gt; it's residing in our SPD-library, &lt;STRONG&gt;SPD_LIB&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;There is a view on this table that only points to 1/3 of it, so I already planned to avoid to use the entire table in the final solution.&amp;nbsp; Let's&amp;nbsp; for the sake of the example say the view is&amp;nbsp;&lt;STRONG&gt;TABLE_1&lt;/STRONG&gt; in &lt;STRONG&gt;LIB_X&lt;/STRONG&gt;. I first coded a test SQL program to see if the code works on 1/1000.000th of all the rows in the actual table.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Then there is a lookup table &lt;/SPAN&gt;&lt;STRONG&gt;TABLE_2&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;in WORK with the same variable &lt;/SPAN&gt;&lt;STRONG&gt;altered_dttm&lt;/STRONG&gt;&lt;SPAN&gt;. Yes they have the same name and this should not be a problem. ChatGTP likes me to rename the one in the lookup table.&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt; Both tables have a unique composite key (PRIMKEY) build by the variables &lt;/SPAN&gt;account_key&lt;SPAN&gt;&amp;nbsp; and &lt;/SPAN&gt;valid_from_dt.&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;You guessed it ... I need to replace the variable&amp;nbsp;altered_dttm in table TABLE_1 if it is missing but not missing in TABLE_2. That is all really. Should be simple. Apparently not when it's HUGE for SQL ... or in a data step (replace) with a composite key.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So to test my SQL program I took a a tiny part of the TABLE_1 and called it &lt;STRONG&gt;TABLE_1_TEST&lt;/STRONG&gt; in WORK. I made sure that all the relevant observations (with the same&amp;nbsp;account_key&amp;nbsp;and valid_to_dttm. ) were present&amp;nbsp;and some more, to test-run and see if it worked.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#339966"&gt;&lt;U&gt;My test program:&amp;nbsp;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;%LET T1 = TABLE_1_TEST;&lt;/DIV&gt;
&lt;DIV&gt;%LET T2 = TABLE_2;&lt;/DIV&gt;
&lt;DIV&gt;%LET Variable = ALTERED_DTTM;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; proc sql;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; update &amp;amp;T1. as a&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; set &amp;amp;Variable. = (select b.&amp;amp;Variable.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from &amp;amp;T2 as b&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;where a.account_key = b.account_key&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and a.valid_from_dt = b.valid_from_dt)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; where missing(a.&amp;amp;Variable.)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; and exists (select 1&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from &amp;amp;T2. as b&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; where a.account_key = b.account_key&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and a.valid_from_dt = b.valid_from_dt)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;;quit;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;That SQL works exactly as I want.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; I got all the missing dates written in the observations where they were missing.&amp;nbsp; A happy man!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#339966"&gt;&lt;U&gt;Then I tried to run it on the view.&amp;nbsp;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;%LET T1 = LIB_X.TABLE_1;&amp;nbsp; &amp;nbsp; /* So I chose a view and not the entire MEGA table that resides in SPD_LIB ! */&lt;/DIV&gt;
&lt;DIV&gt;%LET T2 = TABLE_2;&lt;/DIV&gt;
&lt;DIV&gt;%LET Variable = ALTERED_DTTM;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;The code started to run but ... nothing seemed to happen. Or maybe it was. I checked in putty (not sure how you guys monitor your PIDS) and the process was using almost a 100% of the CPU but the status was S ... sleeping. Waiting for something. Nobody on the system. I am not sure how SQL works with this when the amounts of data become 10.000 fold.&amp;nbsp; I canceled by job after two hours and checked. Nothing was changed. Actually good for the moment. You don't want half of it done ...&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I mentioned this to ChatGTP.&amp;nbsp; I got an explanation that SQL can have difficulties with huge indexed tables. It suggested to fix it with a a modify-replace datastep or with hash object approach. I preferred the former since it looks familiar. It never came with a solution that worked. The problem being the composite key.&amp;nbsp; It came with various "key=" options but non that worked. After various tries I thought: let's try that hash option. Also didn't work.&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I feel a little embarrassed to ask you guys since this should be school stuff. But I never solved this with a table this size. I am sure a Data Step&amp;nbsp; with modify 'n replace can use the index properly and not run through the entire table (if that is what SQL is doing ... worked fine on my little test dataset but not on REAL deal.).&amp;nbsp; &lt;FONT color="#339966"&gt;&lt;STRONG&gt;S o&amp;nbsp; &amp;nbsp; a n y b o d y&amp;nbsp; &amp;nbsp; ???!!!&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 19:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941838#M369445</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2024-08-29T19:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Update HUGE indexed table with SQL (in SPD library) seems not to run at all.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941843#M369446</link>
      <description>&lt;P&gt;If your source is actually a view then you can't update it. A View is basically a set of instructions on how to extract/manipulate values from existing data. As such attempting to "update values" doesn't mean anything as views do not actually contain values just those instructions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 19:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941843#M369446</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-29T19:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Update HUGE indexed table with SQL (in SPD library) seems not to run at all.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941857#M369449</link>
      <description>&lt;P&gt;Aha ... so I need the full monty if I want to do it that way.&amp;nbsp; So you are saying that running with a Datastep would not help me a bit. I still cannot use the view. Right?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 20:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941857#M369449</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2024-08-29T20:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Update HUGE indexed table with SQL (in SPD library) seems not to run at all.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941859#M369450</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18088"&gt;@Longimanus&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Aha ... so I need the full monty if I want to do it that way.&amp;nbsp; So you are saying that running with a Datastep would not help me a bit. I still cannot use the view. Right?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not to change values in a view.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Performance issues with large data sets I often suggest talking to the data base manager or other people involved in managing the data. It may be that you can provide them the data from SAS and have them update the data set. Or use "pass through" code to call external database management tools to work with that. I don't work with SPD so I'm not sure if this is an option.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 21:08:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941859#M369450</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-29T21:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Update HUGE indexed table with SQL (in SPD library) seems not to run at all.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941865#M369452</link>
      <description>&lt;P&gt;It's almost midnight and nobody is on the system ... so I decided to run on the REAL DEAL. The big table in the SPD library. It ran through it all in less than 10 minutes. Yes ... and the updates are correct. What a relieve. Thanx for the feedback. Yes&amp;nbsp; ... I can retrieve a data from a view ... but not update it. "Of course" I think now. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Duh!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 21:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-HUGE-indexed-table-with-SQL-in-SPD-library-seems-not-to/m-p/941865#M369452</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2024-08-29T21:50:46Z</dc:date>
    </item>
  </channel>
</rss>

