<?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: Capture value from row in table base column values in EG in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700356#M37670</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/91583"&gt;@gregor1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have the following table in SAS EG:&lt;/P&gt;
&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Referral Type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Vol&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;365 Days Ago&amp;nbsp; &amp;nbsp; Vol 365 Days Ago&lt;/P&gt;
&lt;P&gt;11/19/2020&amp;nbsp; &amp;nbsp;BUSINESS RULES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;21&amp;nbsp; &amp;nbsp; 11/20/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;11/19/2020&amp;nbsp; &amp;nbsp;OTHER DEPT RFRRLS&amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; 11/20/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;BR /&gt;11/18/2020&amp;nbsp; &amp;nbsp;BUSINESS RULES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1267&amp;nbsp; &amp;nbsp; 11/19/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;11/18/2020&amp;nbsp; &amp;nbsp;PROPERTY SURVEY&amp;nbsp; &amp;nbsp; &amp;nbsp;144&amp;nbsp; &amp;nbsp; 11/19/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;11/18/2020&amp;nbsp; &amp;nbsp;OTHER DEPT RFRRLS&amp;nbsp; &amp;nbsp; 69&amp;nbsp; &amp;nbsp; 11/19/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "365 Days Ago" column is calculated&amp;nbsp;by this formula:&lt;/P&gt;
&lt;P&gt;INTNX('day',t1.REFERRED_DATE, -365)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Volume that corresponds to the&amp;nbsp;"365 Days Ago" date and the&amp;nbsp;Referral Type is further down in the table in the "Vol" column.&amp;nbsp; I am trying to get the value from the "Vol" column to populate the "Vol 365 Days Ago" column, where the values in "Date" column and the "Referral Type" align with the "365 Days Ago" value.&amp;nbsp; Fore example, if the volume for the date of&amp;nbsp;11/20/2019 where the type is&amp;nbsp;BUSINESS RULES is 50, then the first row returned would be:&lt;/P&gt;
&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Referral Type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Vol&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;365 Days Ago&amp;nbsp; &amp;nbsp; Vol 365 Days Ago&lt;/P&gt;
&lt;P&gt;11/19/2020&amp;nbsp; &amp;nbsp;BUSINESS RULES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;21&amp;nbsp; &amp;nbsp; 11/20/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been search the Community library but not finding what I need.&amp;nbsp; Any thoughts/ideas?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One way to do such is to use Proc SQL with a reflexive join (the table with itself).&lt;/P&gt;
&lt;P&gt;Since you did not provide any values that "match" can't provide code for that.&lt;/P&gt;
&lt;P&gt;Here is an example of a reflexive join on a single value:&lt;/P&gt;
&lt;PRE&gt;data have;
   do time = 1 to 50;
      value = rand('integer',10);
      output;
   end;
run;

proc sql;
   create table want as
   select a.time,a.value
          ,b.time as otime, b.value as ovalue
   from have as a
        left join
        have as b
        on (a.time - 12)=b.time
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;You could use your intnx expression for one of the sides, such as the (a.time -12).&lt;/P&gt;
&lt;P&gt;Add other requirements that must match to the ON by using "and a.variablename = b.variablename" for simple matches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The join done this way may find more than one match depending on your data and each match will be in the output.&lt;/P&gt;
&lt;P&gt;Note that actually creating the additional date variable is not needed. If you remove the "b.time as otime" you still get the ovalue that corresponds.&lt;/P&gt;
&lt;P&gt;Use of a Left join this way will have all of the records in the have set appear at least once. If you want records in the output that only have the corresponding Ovalue you could add a : Where not missing(b.value) after the ON.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Nov 2020 21:38:17 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-11-19T21:38:17Z</dc:date>
    <item>
      <title>Capture value from row in table base column values in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700340#M37668</link>
      <description>&lt;P&gt;I have the following table in SAS EG:&lt;/P&gt;&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Referral Type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Vol&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;365 Days Ago&amp;nbsp; &amp;nbsp; Vol 365 Days Ago&lt;/P&gt;&lt;P&gt;11/19/2020&amp;nbsp; &amp;nbsp;BUSINESS RULES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;21&amp;nbsp; &amp;nbsp; 11/20/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;11/19/2020&amp;nbsp; &amp;nbsp;OTHER DEPT RFRRLS&amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; 11/20/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;BR /&gt;11/18/2020&amp;nbsp; &amp;nbsp;BUSINESS RULES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1267&amp;nbsp; &amp;nbsp; 11/19/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;11/18/2020&amp;nbsp; &amp;nbsp;PROPERTY SURVEY&amp;nbsp; &amp;nbsp; &amp;nbsp;144&amp;nbsp; &amp;nbsp; 11/19/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;11/18/2020&amp;nbsp; &amp;nbsp;OTHER DEPT RFRRLS&amp;nbsp; &amp;nbsp; 69&amp;nbsp; &amp;nbsp; 11/19/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The "365 Days Ago" column is calculated&amp;nbsp;by this formula:&lt;/P&gt;&lt;P&gt;INTNX('day',t1.REFERRED_DATE, -365)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Volume that corresponds to the&amp;nbsp;"365 Days Ago" date and the&amp;nbsp;Referral Type is further down in the table in the "Vol" column.&amp;nbsp; I am trying to get the value from the "Vol" column to populate the "Vol 365 Days Ago" column, where the values in "Date" column and the "Referral Type" align with the "365 Days Ago" value.&amp;nbsp; Fore example, if the volume for the date of&amp;nbsp;11/20/2019 where the type is&amp;nbsp;BUSINESS RULES is 50, then the first row returned would be:&lt;/P&gt;&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Referral Type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Vol&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;365 Days Ago&amp;nbsp; &amp;nbsp; Vol 365 Days Ago&lt;/P&gt;&lt;P&gt;11/19/2020&amp;nbsp; &amp;nbsp;BUSINESS RULES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;21&amp;nbsp; &amp;nbsp; 11/20/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been search the Community library but not finding what I need.&amp;nbsp; Any thoughts/ideas?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 21:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700340#M37668</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2020-11-19T21:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Capture value from row in table base column values in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700355#M37669</link>
      <description>It's a straightforward merge, but do you want 365 days ago or one year ago?&lt;BR /&gt;Those are technically different as you can see in your example above. &lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select t1.*, t2.vol as vol_365daysago&lt;BR /&gt;from have as t1&lt;BR /&gt;left join have t2&lt;BR /&gt;on t1.date_365daysago = t2.date&lt;BR /&gt;and t1.referral_type = t2.referral_type;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;I suspect that will need not work for your actual problem as the join needs to join on other factors than just date and referral type, likely an ID of some kind but should get you started.&lt;BR /&gt;&lt;A href="https://www.listendata.com/2014/06/proc-sql-merging.html" target="_blank"&gt;https://www.listendata.com/2014/06/proc-sql-merging.html&lt;/A&gt;</description>
      <pubDate>Thu, 19 Nov 2020 21:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700355#M37669</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-11-19T21:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Capture value from row in table base column values in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700356#M37670</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/91583"&gt;@gregor1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have the following table in SAS EG:&lt;/P&gt;
&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Referral Type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Vol&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;365 Days Ago&amp;nbsp; &amp;nbsp; Vol 365 Days Ago&lt;/P&gt;
&lt;P&gt;11/19/2020&amp;nbsp; &amp;nbsp;BUSINESS RULES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;21&amp;nbsp; &amp;nbsp; 11/20/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;11/19/2020&amp;nbsp; &amp;nbsp;OTHER DEPT RFRRLS&amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; 11/20/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;BR /&gt;11/18/2020&amp;nbsp; &amp;nbsp;BUSINESS RULES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1267&amp;nbsp; &amp;nbsp; 11/19/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;11/18/2020&amp;nbsp; &amp;nbsp;PROPERTY SURVEY&amp;nbsp; &amp;nbsp; &amp;nbsp;144&amp;nbsp; &amp;nbsp; 11/19/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;11/18/2020&amp;nbsp; &amp;nbsp;OTHER DEPT RFRRLS&amp;nbsp; &amp;nbsp; 69&amp;nbsp; &amp;nbsp; 11/19/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "365 Days Ago" column is calculated&amp;nbsp;by this formula:&lt;/P&gt;
&lt;P&gt;INTNX('day',t1.REFERRED_DATE, -365)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Volume that corresponds to the&amp;nbsp;"365 Days Ago" date and the&amp;nbsp;Referral Type is further down in the table in the "Vol" column.&amp;nbsp; I am trying to get the value from the "Vol" column to populate the "Vol 365 Days Ago" column, where the values in "Date" column and the "Referral Type" align with the "365 Days Ago" value.&amp;nbsp; Fore example, if the volume for the date of&amp;nbsp;11/20/2019 where the type is&amp;nbsp;BUSINESS RULES is 50, then the first row returned would be:&lt;/P&gt;
&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Referral Type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Vol&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;365 Days Ago&amp;nbsp; &amp;nbsp; Vol 365 Days Ago&lt;/P&gt;
&lt;P&gt;11/19/2020&amp;nbsp; &amp;nbsp;BUSINESS RULES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;21&amp;nbsp; &amp;nbsp; 11/20/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been search the Community library but not finding what I need.&amp;nbsp; Any thoughts/ideas?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One way to do such is to use Proc SQL with a reflexive join (the table with itself).&lt;/P&gt;
&lt;P&gt;Since you did not provide any values that "match" can't provide code for that.&lt;/P&gt;
&lt;P&gt;Here is an example of a reflexive join on a single value:&lt;/P&gt;
&lt;PRE&gt;data have;
   do time = 1 to 50;
      value = rand('integer',10);
      output;
   end;
run;

proc sql;
   create table want as
   select a.time,a.value
          ,b.time as otime, b.value as ovalue
   from have as a
        left join
        have as b
        on (a.time - 12)=b.time
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;You could use your intnx expression for one of the sides, such as the (a.time -12).&lt;/P&gt;
&lt;P&gt;Add other requirements that must match to the ON by using "and a.variablename = b.variablename" for simple matches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The join done this way may find more than one match depending on your data and each match will be in the output.&lt;/P&gt;
&lt;P&gt;Note that actually creating the additional date variable is not needed. If you remove the "b.time as otime" you still get the ovalue that corresponds.&lt;/P&gt;
&lt;P&gt;Use of a Left join this way will have all of the records in the have set appear at least once. If you want records in the output that only have the corresponding Ovalue you could add a : Where not missing(b.value) after the ON.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 21:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700356#M37670</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-19T21:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Capture value from row in table base column values in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700365#M37671</link>
      <description>&lt;P&gt;Are your data sorted chronologically?&amp;nbsp; If so, then you can maintain a volume history in an array, such that when you encounter a give date and and referral type, you can retrieve the volume for that referral type from 365 days prior:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let hist_beg=%sysevalf("01jan2018"d);
%let hist_end=%sysevalf("31dec2020"d);

data want (drop=_:);
  set have;

  array vol_hist {3,&amp;amp;hist_beg:&amp;amp;hist_end} _temporary_;
  date_365_days_ago=intnx('day',date,-365);
  select(referral_type);
    when ("BUSINESS RULES")    _row=1;
    when ("OTHER DEPT RFRRLS") _row=2;
    when ("PROPERTY SURVEY")   _row=3;
  end;
  vol_365_days_ago=vol_hist{_row,date_365_days_ago};
  vol_hist{_row,date}=vol;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The temporary array VOL_HIST in this example has 3 rows, one for each referral type.&amp;nbsp; And it has one column for your historical period (I set it to 01jan2019 through 31dec2020, but you can easily change it.&amp;nbsp; But of indexing the column numbers as 1,2, 3, ..., it is indexed on the underlying date values 01jan2018, 02jan2018, ... 31dec2020.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VOL_HIST has hundreds of data elements, but because it is a temporary array, there won't be hundreds of variables added to your output data set.&amp;nbsp; And it's values will not be reset to missing with each incoming observation - that's why it can hold a historic series of values.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 22:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700365#M37671</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-11-19T22:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Capture value from row in table base column values in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700551#M37673</link>
      <description>Thanks Mkeintz! Great explanation and I will give it a try.</description>
      <pubDate>Fri, 20 Nov 2020 16:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700551#M37673</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2020-11-20T16:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Capture value from row in table base column values in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700552#M37674</link>
      <description>Thanks Ballardw! I figured out using this method after I presented my problem but before you replied. I truly appreciate you help and response.</description>
      <pubDate>Fri, 20 Nov 2020 16:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700552#M37674</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2020-11-20T16:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Capture value from row in table base column values in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700558#M37675</link>
      <description>Thanks Reeza for your reply! I kept working on it after I posted my problem and came up with a similar approach as yours and it worked. I truly appreciate your help and response. Thanks!</description>
      <pubDate>Fri, 20 Nov 2020 16:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Capture-value-from-row-in-table-base-column-values-in-EG/m-p/700558#M37675</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2020-11-20T16:51:23Z</dc:date>
    </item>
  </channel>
</rss>

