<?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 replace updated values with the original ones? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-updated-values-with-the-original-ones/m-p/325865#M72516</link>
    <description>&lt;P&gt;Assuming that &lt;STRONG&gt;new&lt;/STRONG&gt; is greater than &lt;STRONG&gt;old&lt;/STRONG&gt;, you can use the &lt;STRONG&gt;subgraphs&lt;/STRONG&gt; macro (attached):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input old new;
datalines;
1 2
2 5
3 4
7 8
4 6
5 9
;

%include "&amp;amp;sasforum.\subgraphsmacro.sas" / source2;

%subgraphs(have,from=old,to=new);

proc sql;

create table origin as
select node, min(node) as original
from clusters
group by clust;

create table want as
select have.*, original
from have, origin
where old=node;

quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 19 Jan 2017 03:46:48 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2017-01-19T03:46:48Z</dc:date>
    <item>
      <title>How to replace updated values with the original ones?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-updated-values-with-the-original-ones/m-p/325863#M72515</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with multiple updates&amp;nbsp;of the initial value.&amp;nbsp;Data is generated in such a way that&amp;nbsp;new value becomes a reference number&amp;nbsp;in case of&amp;nbsp;subsequent update. There are multiple update sequences&amp;nbsp;without any particular order and of different length.&amp;nbsp;My goal is to add a column with the original old value for all rows belonging to the same sequence of updates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is how it looks like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;old new&lt;/P&gt;&lt;P&gt;1 2&lt;/P&gt;&lt;P&gt;2 5&lt;/P&gt;&lt;P&gt;3 4&lt;/P&gt;&lt;P&gt;7 8&lt;/P&gt;&lt;P&gt;4 6&lt;/P&gt;&lt;P&gt;5 9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is how I want it to look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;old new original&lt;/P&gt;&lt;P&gt;1 2 1&lt;/P&gt;&lt;P&gt;2 5 1&lt;/P&gt;&lt;P&gt;3 4 3&lt;/P&gt;&lt;P&gt;7 8&amp;nbsp;7&lt;/P&gt;&lt;P&gt;4 6 3&lt;/P&gt;&lt;P&gt;5 9 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 02:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-updated-values-with-the-original-ones/m-p/325863#M72515</guid>
      <dc:creator>Financier</dc:creator>
      <dc:date>2017-01-19T02:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace updated values with the original ones?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-updated-values-with-the-original-ones/m-p/325865#M72516</link>
      <description>&lt;P&gt;Assuming that &lt;STRONG&gt;new&lt;/STRONG&gt; is greater than &lt;STRONG&gt;old&lt;/STRONG&gt;, you can use the &lt;STRONG&gt;subgraphs&lt;/STRONG&gt; macro (attached):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input old new;
datalines;
1 2
2 5
3 4
7 8
4 6
5 9
;

%include "&amp;amp;sasforum.\subgraphsmacro.sas" / source2;

%subgraphs(have,from=old,to=new);

proc sql;

create table origin as
select node, min(node) as original
from clusters
group by clust;

create table want as
select have.*, original
from have, origin
where old=node;

quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jan 2017 03:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-updated-values-with-the-original-ones/m-p/325865#M72516</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-01-19T03:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace updated values with the original ones?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-updated-values-with-the-original-ones/m-p/326102#M72581</link>
      <description>&lt;P&gt;Thank you! It works.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 20:05:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-updated-values-with-the-original-ones/m-p/326102#M72581</guid>
      <dc:creator>Financier</dc:creator>
      <dc:date>2017-01-19T20:05:03Z</dc:date>
    </item>
  </channel>
</rss>

