<?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: Selecting data based on Index in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471863#M120898</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If you simply want to pull the factor from the variable&amp;nbsp;&lt;SPAN&gt;FactorAtTime7 when&amp;nbsp;TimeSincePurchase=7 in t1, then pulling this value by its relative position in the data set is not the way to go.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use the &lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1x70jnnpttwy0n1gf5rvuivgyry.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=da" target="_self"&gt;VVALUEX Funtion&lt;/A&gt; as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, but do not set&amp;nbsp;time=timeSincePurchase+3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good catch, thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216759"&gt;@ProcLunchbreak&lt;/a&gt;&amp;nbsp;use Arrays or VVALUEX. Both are illustrated, you can play around to ensure you have the right index set up.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jun 2018 19:40:30 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-06-20T19:40:30Z</dc:date>
    <item>
      <title>Selecting data based on Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471836#M120884</link>
      <description>&lt;P&gt;I have two tables, &lt;FONT face="courier new,courier"&gt;t1&lt;/FONT&gt;&amp;nbsp;is filled with all purchase records and is laid out like so:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;CustomerID|ProductID|PurchaseAge|TimeSincePurchase|&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;A00001&amp;nbsp; &amp;nbsp; |0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|23&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;A00001&amp;nbsp; &amp;nbsp; |0002&amp;nbsp; &amp;nbsp; &amp;nbsp;|29&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;A00002&amp;nbsp; &amp;nbsp; |0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|65&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|13&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;t2 &lt;FONT face="arial,helvetica,sans-serif"&gt;is in the layout of:&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ProductID|PurchaseAge|FactorAtTime0|&lt;SPAN&gt;FactorAtTime1|...|FactorAtTime120|&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|...|&amp;nbsp; &amp;nbsp; &amp;nbsp; ...&amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|19&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|...|&amp;nbsp; &amp;nbsp; &amp;nbsp; ...&amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;...&amp;nbsp; &amp;nbsp; &amp;nbsp; |...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|...|&amp;nbsp; &amp;nbsp; &amp;nbsp; ...&amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0002&amp;nbsp; &amp;nbsp; &amp;nbsp;|18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|...|&amp;nbsp; &amp;nbsp; &amp;nbsp; ...&amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0002&amp;nbsp; &amp;nbsp; &amp;nbsp;|19&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|...|&amp;nbsp; &amp;nbsp; &amp;nbsp; ...&amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;...&amp;nbsp; &amp;nbsp; &amp;nbsp; |...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp;|...|&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;I'm attempting to write a query that would left join on the &lt;FONT face="courier new,courier"&gt;ProductID&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;PurchaseAge&lt;FONT face="arial,helvetica,sans-serif"&gt;&amp;nbsp;characteristics and then pull in the factor from the "&lt;FONT face="courier new,courier"&gt;TimeSincePurchase + 3&lt;/FONT&gt;"-th&amp;nbsp;column&amp;nbsp;of &lt;FONT face="courier new,courier"&gt;t2&lt;FONT face="arial,helvetica,sans-serif"&gt;&amp;nbsp;.&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a method to call columns by their ordinal position within the table as opposed to the name of the column?&lt;/P&gt;&lt;P&gt;If so, can a variable be used in place of a numerical constant?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: As per the below comments, it appears you would have to use a data step rather than sql in order to dynamically pick which column to pull from. The solution I ended up going with was transforming the second table like below then joining on ProductID, PurchaseAge, and TimeSincePurchase.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ProductID|PurchaseAge|TimeSincePurchase|&lt;SPAN&gt;Factor|&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; ..&amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; ..&amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; ..&amp;nbsp;&amp;nbsp;|&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|19&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; ..&amp;nbsp;&amp;nbsp;|&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;...&amp;nbsp; &amp;nbsp; &amp;nbsp; |...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; ..&amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0002&amp;nbsp; &amp;nbsp; &amp;nbsp;|18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; ..&amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0002&amp;nbsp; &amp;nbsp; &amp;nbsp;|19&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; ..&amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;...&amp;nbsp; &amp;nbsp; &amp;nbsp; |...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; ..&amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 12:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471836#M120884</guid>
      <dc:creator>ProcLunchbreak</dc:creator>
      <dc:date>2018-06-26T12:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data based on Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471840#M120887</link>
      <description>&lt;P&gt;So when&amp;nbsp;&lt;SPAN&gt;TimeSincePurchase=7 you want to pull the factor from t2 from the variable&amp;nbsp;FactorAtTime10 in the record for productID=0001, PurchaseAge=23, correct?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you show us an example of what your desired output looks like?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 19:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471840#M120887</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-06-20T19:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data based on Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471842#M120889</link>
      <description>Use VVALUEX(). &lt;BR /&gt;&lt;BR /&gt;time=timeSincePurchase+3;&lt;BR /&gt;varname = catt('FactorAtTime', put(time, 8. -l));&lt;BR /&gt;want = vvaluex(varname); *you may need to convert this to a number;</description>
      <pubDate>Wed, 20 Jun 2018 19:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471842#M120889</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-20T19:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data based on Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471851#M120894</link>
      <description>&lt;P&gt;When TimeSincePurchase=7 I want to pull the factor from the 10th column in t2, FactorAtTime7.&lt;/P&gt;&lt;P&gt;For Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;t1 record&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;CustomerID|ProductID|PurchaseAge|TimeSincePurchase|&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;&lt;SPAN&gt;A00001&amp;nbsp; &amp;nbsp; |0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|23&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;A00001&amp;nbsp; &amp;nbsp; |0002&amp;nbsp; &amp;nbsp; &amp;nbsp;|29&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;A00002&amp;nbsp; &amp;nbsp; |0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|65&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|13&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and t2 record&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ProductID|PurchaseAge|FactorAtTime0|&lt;SPAN&gt;FactorAtTime1|...|FactorAtTime7|&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|21&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;1.3 &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp;0.2 &amp;nbsp; &amp;nbsp; |...|&amp;nbsp; &amp;nbsp; &amp;nbsp; 0.9&amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;0.6 &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp;5.1 &amp;nbsp; &amp;nbsp; |...|&amp;nbsp; &amp;nbsp; &amp;nbsp; 4.7&amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&lt;FONT color="#0000FF"&gt;0001&lt;/FONT&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;FONT color="#0000FF"&gt;23&amp;nbsp;&lt;/FONT&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;1.7&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;2.3 &amp;nbsp; &amp;nbsp; |...|&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#FF0000"&gt;6.8&lt;/FONT&gt;&amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;would create&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;CustomerID|ProductID|PurchaseAge|TimeSincePurchase|CurrentFactor&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&lt;FONT color="#0000FF"&gt;A00001&amp;nbsp; &amp;nbsp; |0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|23&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/FONT&gt; |&lt;FONT color="#FF0000"&gt;6.8&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;A00001&amp;nbsp; &amp;nbsp; |0002&amp;nbsp; &amp;nbsp; &amp;nbsp;|29&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;A00002&amp;nbsp; &amp;nbsp; |0001&amp;nbsp; &amp;nbsp; &amp;nbsp;|65&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|13&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 19:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471851#M120894</guid>
      <dc:creator>ProcLunchbreak</dc:creator>
      <dc:date>2018-06-20T19:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data based on Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471852#M120895</link>
      <description>&lt;P&gt;An array is another option but note that you start at 0, so make sure it's +3 that you actually want which would return FactorAtTime 11 since SAS indexes from 1, not 0.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array factorT(*) factorAtTime0 - factorAtTime120;

Value = factort(timesincePurchase-1);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 19:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471852#M120895</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-20T19:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data based on Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471853#M120896</link>
      <description>&lt;P&gt;If you simply want to pull the factor from the variable&amp;nbsp;&lt;SPAN&gt;FactorAtTime7 when&amp;nbsp;TimeSincePurchase=7 in t1, then pulling this value by its relative position in the data set is not the way to go.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use the &lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1x70jnnpttwy0n1gf5rvuivgyry.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=da" target="_self"&gt;VVALUEX Funtion&lt;/A&gt; as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, but do not set&amp;nbsp;time=timeSincePurchase+3.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 19:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471853#M120896</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-06-20T19:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data based on Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471863#M120898</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If you simply want to pull the factor from the variable&amp;nbsp;&lt;SPAN&gt;FactorAtTime7 when&amp;nbsp;TimeSincePurchase=7 in t1, then pulling this value by its relative position in the data set is not the way to go.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use the &lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1x70jnnpttwy0n1gf5rvuivgyry.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=da" target="_self"&gt;VVALUEX Funtion&lt;/A&gt; as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, but do not set&amp;nbsp;time=timeSincePurchase+3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good catch, thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216759"&gt;@ProcLunchbreak&lt;/a&gt;&amp;nbsp;use Arrays or VVALUEX. Both are illustrated, you can play around to ensure you have the right index set up.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 19:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471863#M120898</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-20T19:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data based on Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471875#M120900</link>
      <description>&lt;P&gt;I'm getting a syntax error immediately after VVALUEX with the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC SQL;
     SELECT
     t1.CustomerID,
     t1.ProductID,
     t1.PurchaseAge,
     t1.TimeSincePurchase,
     (t2.VVALUEX(CATT('FactorAtTime', PUT(t1.TimeSincePurchase, 8., -l)))) AS CurrentFactor
     FROM WORK.PurchaseRecords t1
     LEFT JOIN WORK.ProductFactors t2 ON (t1.ProductID = t2.ProductID) AND (t1.PurchaseAge =
t2.PurchaseAge)
;QUIT;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Is this is something I should be trying in a datastep rather than SQL? &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 19:59:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471875#M120900</guid>
      <dc:creator>ProcLunchbreak</dc:creator>
      <dc:date>2018-06-20T19:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data based on Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471878#M120903</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216759"&gt;@ProcLunchbreak&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Is this is something I should be trying in a datastep rather than SQL? &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, AFAIK SQL doesn't have a dynamic method of referencing columns without knowing it ahead of time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 20:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-data-based-on-Index/m-p/471878#M120903</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-20T20:01:22Z</dc:date>
    </item>
  </channel>
</rss>

