<?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 statement taking too much time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926314#M364526</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp; Thanks for the comparision and helping out with the efficient way to update. Indeed modify satatement is the better option.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Mushy&lt;/P&gt;</description>
    <pubDate>Mon, 29 Apr 2024 14:50:01 GMT</pubDate>
    <dc:creator>Mushy</dc:creator>
    <dc:date>2024-04-29T14:50:01Z</dc:date>
    <item>
      <title>Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/925988#M364374</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am updating huge table using update statement in proc sql.&lt;/P&gt;
&lt;P&gt;Its taking very long time.&lt;/P&gt;
&lt;P&gt;I need to just blank/null few char/num fields in the tables based of the dataset that provides the fields to be blanked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Is there an efficient way to deal with this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mushy&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 11:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/925988#M364374</guid>
      <dc:creator>Mushy</dc:creator>
      <dc:date>2024-04-26T11:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/925989#M364375</link>
      <description>&lt;P&gt;To enable others to help more effectively, please share your SQL code, the log, and a sample of the table data (or at least a good description of the columns you are working with and the number of rows involved).&amp;nbsp; Is your data in base SAS or in some external database?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 12:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/925989#M364375</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-04-26T12:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/925990#M364376</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with SAS datasets:&lt;/P&gt;
&lt;P&gt;In general for my case do you know a better and efficient way to update columns other than proc sql update statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The query I am using is:&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;/P&gt;
&lt;P&gt;update liba.geography set country1='', country3='', pop1=., pop2=., pop1_date=.;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;it is a table with 10m + records and 40+ fields.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;real time 11:49.60&lt;BR /&gt;user cpu time 11:25.46&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 12:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/925990#M364376</guid>
      <dc:creator>Mushy</dc:creator>
      <dc:date>2024-04-26T12:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/925992#M364378</link>
      <description>&lt;P&gt;Why do you need to update an existing dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general with SAS datasets I never use SQL UPDATE.&amp;nbsp; Instead I just create a program to MAKE the new dataset I need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your example code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
update liba.geography set country1='', country3='', pop1=., pop2=., pop1_date=.;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would normally run as :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data liba.geography;
  set liba.geography;
  call missing(of country1 country3 pop1 pop2 pop1_date);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 12:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/925992#M364378</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-26T12:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926002#M364383</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; Indeed its faster , but we lose index after the set.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 13:15:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926002#M364383</guid>
      <dc:creator>Mushy</dc:creator>
      <dc:date>2024-04-26T13:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926004#M364384</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393424"&gt;@Mushy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; Indeed its faster , but we lose index after the set.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And why does the index matter?&lt;/P&gt;
&lt;P&gt;If it is important then you can simple create the index also, easiest is to just include its definition in the DATA statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new(index=(.....));
  set old;
  ...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if speed is an issue it is frequently much faster to make the dataset first and then create the index later. You can use PROC DATASETS or PROC SQL to create an index on an existing dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I am still curious what application is that requires you to update an existing dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 13:21:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926004#M364384</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-26T13:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926073#M364408</link>
      <description>&lt;P&gt;You could use a DATA step with a MODIFY statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data liba.geography ;
	modify liba.geography; 
	call missing(country1, country3,pop1,pop2,pop1_date);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That should run faster for you. If you are nulling values for variables involved in the index, your index isn't going to be worth much after the update anyway. In that case,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s advice is best all-around: re-create the data set, do any additional data manipulation, and then rebuild the index in a separate step.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 17:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926073#M364408</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-04-26T17:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926078#M364409</link>
      <description>&lt;P&gt;You could skip reassignment by dropping&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class(index=(name/unique));
   if 0 then set sashelp.class;
   set sashelp.class(drop=age weight);
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 297px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95946i57B7EB1A0A9A54EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393424"&gt;@Mushy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am updating huge table using update statement in proc sql.&lt;/P&gt;
&lt;P&gt;Its taking very long time.&lt;/P&gt;
&lt;P&gt;I need to just blank/null few char/num fields in the tables based of the dataset that provides the fields to be blanked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Is there an efficient way to deal with this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mushy&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 17:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926078#M364409</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-04-26T17:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926132#M364432</link>
      <description>&lt;P&gt;You could drop these variables firstly, after that adding these variables in this table .&lt;/P&gt;
&lt;P&gt;Here is an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.class;
run;


proc sql;
alter table have
drop name,age
add name char(20),age num;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 27 Apr 2024 06:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926132#M364432</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-04-27T06:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926294#M364522</link>
      <description>&lt;P&gt;This summarizes the results of the original code and responses received as of this date when executed against this table:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Contents: Attributes" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Data Set Name&lt;/TH&gt;
&lt;TD class="l data"&gt;LIBA.HAVE&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Observations&lt;/TH&gt;
&lt;TD class="l data"&gt;500000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Member Type&lt;/TH&gt;
&lt;TD class="l data"&gt;DATA&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Variables&lt;/TH&gt;
&lt;TD class="l data"&gt;50&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Engine&lt;/TH&gt;
&lt;TD class="l data"&gt;V9&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Indexes&lt;/TH&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Created&lt;/TH&gt;
&lt;TD class="l data"&gt;04/29/2024 09:02:45&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Observation Length&lt;/TH&gt;
&lt;TD class="l data"&gt;400&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Last Modified&lt;/TH&gt;
&lt;TD class="l data"&gt;04/29/2024 09:02:45&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Deleted Observations&lt;/TH&gt;
&lt;TD class="l data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Protection&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Compressed&lt;/TH&gt;
&lt;TD class="l data"&gt;NO&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Data Set Type&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Sorted&lt;/TH&gt;
&lt;TD class="l data"&gt;NO&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Label&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Data Representation&lt;/TH&gt;
&lt;TD class="l data"&gt;WINDOWS_64&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Encoding&lt;/TH&gt;
&lt;TD class="l data"&gt;utf-8 Unicode (UTF-8)&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Original Code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	update liba.have set country1='', country3='', pop1=., pop2=., pop1_date=.;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;NOTE: PROCEDURE SQL used (Total process time):
      real time           0.61 seconds
      cpu time            0.23 seconds
&lt;/PRE&gt;
&lt;P&gt;So, .61 seconds was the time to beat!&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s solution&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data liba.have(index=(ID));
  set liba.have;
  call missing(of country1 country3 pop1 pop2 pop1_date);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;'s solution&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
alter table have
drop country1, country3,pop1,pop2,pop1_date
add country1 char(20), country3 char(3),pop1 num,pop2 num,pop1_date num;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;tied for first place&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;      real time           0.40 seconds
      cpu time            0.20 seconds
&lt;/PRE&gt;
&lt;P&gt;With my solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data liba.have ;
   modify liba.have;
   call missing(country1, country3,pop1,pop2,pop1_date);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;coming in third,&lt;/P&gt;
&lt;PRE&gt;      real time           0.44 seconds
      cpu time            0.32 seconds&lt;/PRE&gt;
&lt;P&gt;and &lt;A class="trigger-hovercard" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410" target="_blank" rel="noopener"&gt;data_null__&lt;/A&gt;'s solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data liba.have (index=(ID));
	if 0 then set liba.have; 
	set liba.have (drop=country1 country3 pop1 pop2 pop1_date);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;still beating the original post:&lt;/P&gt;
&lt;PRE&gt;      real time           0.58 seconds
      cpu time            0.26 seconds
&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Of course, your mileage may vary depending on the size of your data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 29 Apr 2024 13:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926294#M364522</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-04-29T13:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Update statement taking too much time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926314#M364526</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp; Thanks for the comparision and helping out with the efficient way to update. Indeed modify satatement is the better option.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Mushy&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 14:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-statement-taking-too-much-time/m-p/926314#M364526</guid>
      <dc:creator>Mushy</dc:creator>
      <dc:date>2024-04-29T14:50:01Z</dc:date>
    </item>
  </channel>
</rss>

