<?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 Using two datasets to compute new values in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-two-datasets-to-compute-new-values/m-p/404342#M25941</link>
    <description>&lt;P&gt;Simple data manipulation problemthat I just cannot get past! I have a dataset with the following variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A B C Iter&lt;/P&gt;&lt;P&gt;1 2 9 &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2 5 7 &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;3 9 6 &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;4 1 3 &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also have another dataset with just one row of info.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A_A B_B C_C&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp;7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what i need to do is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For ITER = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First A_A_P1 = A_A + A &amp;nbsp;-&amp;gt; 1 + 1 = 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For subsequent ITER = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A_A_P1 = lag(A_A_P1) + A -&amp;gt; 2 + 2 = 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the A_A_P1 column should look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A_A_P1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For iter = 2, same process but now the values will be under &amp;nbsp;A_A_P2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same process will continue for B and C with respective ITERs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how this can be done efficiently?&lt;/P&gt;</description>
    <pubDate>Mon, 16 Oct 2017 02:39:56 GMT</pubDate>
    <dc:creator>eemrun</dc:creator>
    <dc:date>2017-10-16T02:39:56Z</dc:date>
    <item>
      <title>Using two datasets to compute new values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-two-datasets-to-compute-new-values/m-p/404342#M25941</link>
      <description>&lt;P&gt;Simple data manipulation problemthat I just cannot get past! I have a dataset with the following variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A B C Iter&lt;/P&gt;&lt;P&gt;1 2 9 &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2 5 7 &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;3 9 6 &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;4 1 3 &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also have another dataset with just one row of info.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A_A B_B C_C&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp;7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what i need to do is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For ITER = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First A_A_P1 = A_A + A &amp;nbsp;-&amp;gt; 1 + 1 = 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For subsequent ITER = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A_A_P1 = lag(A_A_P1) + A -&amp;gt; 2 + 2 = 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the A_A_P1 column should look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A_A_P1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For iter = 2, same process but now the values will be under &amp;nbsp;A_A_P2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same process will continue for B and C with respective ITERs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how this can be done efficiently?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 02:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-two-datasets-to-compute-new-values/m-p/404342#M25941</guid>
      <dc:creator>eemrun</dc:creator>
      <dc:date>2017-10-16T02:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using two datasets to compute new values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-two-datasets-to-compute-new-values/m-p/404357#M25942</link>
      <description>&lt;P&gt;1. What&amp;nbsp;would be the output for the sample data you've posted?&lt;/P&gt;
&lt;P&gt;2. What code do you have so far?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 03:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-two-datasets-to-compute-new-values/m-p/404357#M25942</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-16T03:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using two datasets to compute new values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-two-datasets-to-compute-new-values/m-p/404411#M25947</link>
      <description>&lt;P&gt;Start by re-modelling your data so that it is in a simple usable structure, something like:&lt;/P&gt;
&lt;PRE&gt;ITER   CLASS   VALUE  ROWID
1          A            1           1
1          B            2           1
1          C            9           1
1          A            2            2
...

CLASS   VALUE
A             1
B             3
C             7&lt;/PRE&gt;
&lt;P&gt;With this model you can then simply merge the second dataset onto the first one and do your comuptations.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 09:38:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-two-datasets-to-compute-new-values/m-p/404411#M25947</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-16T09:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using two datasets to compute new values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-two-datasets-to-compute-new-values/m-p/404439#M25963</link>
      <description>&lt;P&gt;Here is how to get&amp;nbsp;A_A_P1. But I don't understand your next few questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input A B C Iter;
cards;
1 2 9   1
2 5 7   1
3 9 6   1
4 1 3   2
;
run;
data x;
input A_A B_B C_C;
cards;
1      3      7
;
run;
data want;
 set have;
 if _n_=1 then set x;
 retain A_A_P1;
 if _n_=1 then A_A_P1=A+A_A;
  else A_A_P1=A+A_A_P1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Oct 2017 12:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-two-datasets-to-compute-new-values/m-p/404439#M25963</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-10-16T12:23:14Z</dc:date>
    </item>
  </channel>
</rss>

