<?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 does keep and rename data set options work with set statement with key = option. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-does-keep-and-rename-data-set-options-work-with-set/m-p/826547#M326476</link>
    <description>&lt;P&gt;Interesting. Thank you very much for your explanation! And yeah you are write I miswrote ins2 instead of ins when doing the lookup in the code.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2022 01:15:35 GMT</pubDate>
    <dc:creator>john_floralde</dc:creator>
    <dc:date>2022-08-02T01:15:35Z</dc:date>
    <item>
      <title>How does keep and rename data set options work with set statement with key = option.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-keep-and-rename-data-set-options-work-with-set/m-p/826404#M326420</link>
      <description>&lt;P&gt;We have the following code where we perform a table lookup using set statement with key = option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;*master table;&lt;BR /&gt;data ftr;
 trnid = 'trade1'; &lt;BR /&gt; trnidsce = 'a';&lt;BR /&gt; issueid = '';&lt;BR /&gt; issueidsce = '';&lt;BR /&gt; rcvudlyid = 'ABC';&lt;BR /&gt; rcvudlyidsce = '2';
run;&lt;BR /&gt;&lt;BR /&gt;*lookup&amp;nbsp;table;&lt;BR /&gt;data&amp;nbsp;ins (index = (issueKey = (issueid issueidsce) / unique)) ;&lt;BR /&gt; issueid = 'ABC';&lt;BR /&gt; issueidsce = '2';&lt;BR /&gt;&amp;nbsp;ciultarlvcflg&amp;nbsp;=&amp;nbsp;'Y';&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*final&amp;nbsp;table;&lt;BR /&gt;data&amp;nbsp;final;&lt;BR /&gt;&amp;nbsp;set&amp;nbsp;ftr;&lt;BR /&gt;&amp;nbsp; set&amp;nbsp;ins2&amp;nbsp;(keep&amp;nbsp;=&amp;nbsp;issueid issueidsce ciultarlvcflg&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rename&amp;nbsp;=&amp;nbsp;(issueid&amp;nbsp;=&amp;nbsp;rcvudlyid&lt;BR /&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;issueidsce =&amp;nbsp;rcvudlyidsce))&amp;nbsp;key&amp;nbsp;=&amp;nbsp;issueKey&amp;nbsp;/&amp;nbsp;unique;&lt;BR /&gt;&amp;nbsp; if&amp;nbsp;_iorc_ then&amp;nbsp;_error_ =&amp;nbsp;0;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As I understand the key = option should do the lookup via definition of issueKey, i.e. if issueid and issueidsce is matching between ins2 and ftr dataset. However it seems the&amp;nbsp;lookup is happening by rcvudlyid rcvudlyidsce after the rename and I am now able to get value of ciultarlvcflg. I was expecting it to throw an error given the original variables used to create the index was renamed. Can someone help me to understand what is happening? Many thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="john_floralde_0-1659342836018.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73966i09C81CFE09CFB4A7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="john_floralde_0-1659342836018.png" alt="john_floralde_0-1659342836018.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 08:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-keep-and-rename-data-set-options-work-with-set/m-p/826404#M326420</guid>
      <dc:creator>john_floralde</dc:creator>
      <dc:date>2022-08-01T08:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: How does keep and rename data set options work with set statement with key = option.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-keep-and-rename-data-set-options-work-with-set/m-p/826424#M326431</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/360476"&gt;@john_floralde&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The KEEP= option is (always) applied before the RENAME= option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the key variables in dataset INS were renamed permanently with PROC DATASETS, the index would be modified correspondingly (see PROC CONTENTS output), thus maintaining its integrity. Apparently, SAS handles a temporary renaming via dataset options in a similar way: temporarily the index works with the new names. (I assume that the "&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;" in &lt;FONT face="courier new,courier"&gt;ins&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/FONT&gt; in your code was not intended.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a useful feature because it allows you to create indexed lookup tables without worrying about variable names in future "master" tables. Your example is a case in point, as simply renaming the RCVU... key variables of dataset FTR is not an option because of the existing ISSUE... variables. So, one lookup table can be used for many master tables, regardless of their key variable names.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 12:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-keep-and-rename-data-set-options-work-with-set/m-p/826424#M326431</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-08-01T12:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: How does keep and rename data set options work with set statement with key = option.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-keep-and-rename-data-set-options-work-with-set/m-p/826547#M326476</link>
      <description>&lt;P&gt;Interesting. Thank you very much for your explanation! And yeah you are write I miswrote ins2 instead of ins when doing the lookup in the code.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 01:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-keep-and-rename-data-set-options-work-with-set/m-p/826547#M326476</guid>
      <dc:creator>john_floralde</dc:creator>
      <dc:date>2022-08-02T01:15:35Z</dc:date>
    </item>
  </channel>
</rss>

