<?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: How to reset all values of a dummy var to zero except for rows with max(report_time) per person in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/328435#M62492</link>
    <description />
    <pubDate>Mon, 30 Jan 2017 14:40:03 GMT</pubDate>
    <dc:creator>BLE</dc:creator>
    <dc:date>2017-01-30T14:40:03Z</dc:date>
    <item>
      <title>How to reset all values of a dummy var to zero except for rows with max(report_time) per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/326785#M62343</link>
      <description>&lt;P&gt;I have a table&amp;nbsp;with a dummy var set to 0 for all rows EXCEPT the rows most recently sent for each person.&amp;nbsp; In that case the dummy var should be set to 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dummy var is incorrectly&amp;nbsp;set to 1 for more than just the most recently sent row so I need to reset the dummy var to zero for all rows EXCEPT the rows most recently sent by each person.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a var called report_time and can ID the most recently sent row by using max(report_time).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following syntax did not work:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;update table1&lt;/P&gt;&lt;P&gt;set dummy_var =&lt;/P&gt;&lt;P&gt;case&lt;/P&gt;&lt;P&gt;when max(report_time) = report_time then dummy_var=1&lt;/P&gt;&lt;P&gt;else dummy_var = 0&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;group by person&lt;/P&gt;&lt;P&gt;order by report_time desc, person asc;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below end is the following:&lt;/P&gt;&lt;P&gt;ERROR: The value expression referenced by column dummy_var can not directly contain a summary function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below group is the following:&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/326785#M62343</guid>
      <dc:creator>BLE</dc:creator>
      <dc:date>2017-01-23T17:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to reset all values of a dummy var to zero except for rows with max(report_time) per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/326796#M62344</link>
      <description>&lt;P&gt;You can do it easyly by sort and a data step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have; by person_id report_time; run;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;by person_id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if last.person_id then dummy_var=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else dummy_var=0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 18:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/326796#M62344</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-23T18:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to reset all values of a dummy var to zero except for rows with max(report_time) per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/326819#M62346</link>
      <description>The dataset that needs to be updated is an oracle table. Will it process slower using a sort and data step? Can it be done given the data and the set are the same and are an oracle table?&lt;BR /&gt;</description>
      <pubDate>Mon, 23 Jan 2017 19:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/326819#M62346</guid>
      <dc:creator>BLE</dc:creator>
      <dc:date>2017-01-23T19:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to reset all values of a dummy var to zero except for rows with max(report_time) per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/326822#M62347</link>
      <description>&lt;P&gt;Sorry, I have almost no experience with oracle tables.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 19:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/326822#M62347</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-23T19:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to reset all values of a dummy var to zero except for rows with max(report_time) per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/328434#M62491</link>
      <description>&lt;P&gt;I tested the timing of doing a proc sql update of the rows that needed to be changed from dummy_var = 1 to dummy_var = 0, and found that takes over an hour which is much too long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The next approach I tested was to delete the rows that needed updating, then adding those rows back in but with the correction.&lt;/P&gt;&lt;P&gt;I was surprised to find it takes 10 times&amp;nbsp;longer&amp;nbsp;to delete&amp;nbsp;rows using proc sql than it takes&amp;nbsp;using a data step.&lt;/P&gt;&lt;P&gt;Using proc sql insert is very quick so that is the method I used to get the rows of data back into the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to update an oracle table using base SAS in the most efficient manner and welcome any suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 14:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/328434#M62491</guid>
      <dc:creator>BLE</dc:creator>
      <dc:date>2017-01-30T14:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to reset all values of a dummy var to zero except for rows with max(report_time) per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/328435#M62492</link>
      <description />
      <pubDate>Mon, 30 Jan 2017 14:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/328435#M62492</guid>
      <dc:creator>BLE</dc:creator>
      <dc:date>2017-01-30T14:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to reset all values of a dummy var to zero except for rows with max(report_time) per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/329013#M62530</link>
      <description>Explicit pass-thru&lt;BR /&gt;This allows you to send oracle code from SAS&lt;BR /&gt;Once you have an oracle update working,  then consider how SAS would need to achieve the same thing.... it is not always obvious.&lt;BR /&gt;Good Luck&lt;BR /&gt;PeterC</description>
      <pubDate>Wed, 01 Feb 2017 09:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-reset-all-values-of-a-dummy-var-to-zero-except-for-rows/m-p/329013#M62530</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-02-01T09:31:51Z</dc:date>
    </item>
  </channel>
</rss>

