<?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 create a lookup table from all possible group combination in a row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787201#M251479</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149821"&gt;@bibbnd&lt;/a&gt;&amp;nbsp;, I edited your sample data to be more eaily read.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain your desired logic from there &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;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input group $ (rate1 - rate6)($) amt1 - amt6;
datalines; 
NNN T P 58 49 D  A 2002 554 499 498 484 313 
NNY T P D  49 58 A 1222 900 800 800 750 610 
;

data want;
input GROUP $ CURRENT_RATE $ CURRENT_AMT RATE1 $ AMT1 RATE2 $ AMT2 RATE3 $ AMT3 RATE4 $ AMT4;
infile datalines dlm = ',';
datalines;
NNN,  ,   ,D,484,49,498,58,498,P,554 
NNN,49,498,D,484,58,499,  ,   ,P,554 
NNN,58,499,D,484,49,498,  ,   ,P,554 
NNN,P ,554,D,484,49,498,58,499, ,    
NNN,A ,610,D,484,49,498,58,499,P,554 
NNN,T ,554,D,484,49,498,58,499,P,554 
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 Dec 2021 07:02:39 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2021-12-23T07:02:39Z</dc:date>
    <item>
      <title>How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787194#M251472</link>
      <description>&lt;P&gt;I will try to better explain what i need to do: there are the following rate categores&amp;nbsp;&lt;/P&gt;&lt;P&gt;D, P, T , A , 48,and 59.&lt;/P&gt;&lt;P&gt;They are not chosen in any particular order to be the current rate. I just need all of them to be set to the current rate within a row 1 at a time. I need to create a matrix where each one of the rates are set to be the current rate with each different group .&lt;/P&gt;&lt;P&gt;It doesn't matter which one is selected first or second to start the process.&lt;/P&gt;&lt;P&gt;I pick one of them to be the current rate from a row. After the current rate is set, i than assign the D, 48, or 59 rates in order from smallest corresponding amt to largest corresponding amt within the same row. i don't use the A or T rates in this process. They are only used to be a current rate. I repeat this process with a row until each of the rates have been set to the current rate.&amp;nbsp; Therefore, i will create a total of 6 rows from 1 row by setting each one of the rates to the current rate.&amp;nbsp; I start the process over with the next group once all rates have been set to the current rate.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You only see 3 additional rates options on the HAVE dataset when the current rate is a D, 48, or 59.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;NOTE: I HAVE EDITED MY ORIGINAL POST TO MAKE IT CLEARER AND INCLUDE SUGGESTIONS FROM BELOW.&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input group $ (rate1 - rate6)($) amt1 - amt6;
datalines; 
NNN T P 58 49 D  A 2002 554 499 498 484 313 
NNY T P D  49 58 A 1222 900 800 801 750 610 
;

data want;
input GROUP $ CURRENT_RATE $ CURRENT_AMT RATE1 $ AMT1 RATE2 $ AMT2 RATE3 $ AMT3 RATE4 $ AMT4 RATE5 $ AMT5;
infile datalines dlm = ',';
datalines;
NNN,D,484,49,498,58,498,P,554, , 
NNN,49,498,D,484,58,499,P,554 , ,
NNN,58,499,D,484,49,498,P,554 , , 
NNN,P,554,D,484,49,498,58,499, ,    
NNN,A,610,D,484,49,498,58,499,P,554 
NNN,T,554,D,484,49,498,58,499,P,554 
NNY,T,1222,58,750,D,800,49,800,P,900&lt;BR /&gt;NNY,P,900,58,750,D,800,49,801, , &lt;BR /&gt;NNY,D,800,58,750,49,801,P,900, , &lt;BR /&gt;NNY,49,801,58,750,D,800,P,900, ,  &lt;BR /&gt;NNY,58,750,D,800,49,801,P,901, , &lt;BR /&gt;NNY,A,610,58,750,D,800,49,801,P,900&lt;BR /&gt;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;THIS CODE WAS GIVEN TO ME TO EDIT.  i HAVE NO IDEA HOW TO MAKE IT WORK. &lt;BR /&gt;i HAVE BEEN DOING THIS PROCESS MANUALLY IN EXCEL BUT IT NEEDS TO BE AUTOMATED SINCE THE MATRIX REQUIRES MORE FREQUENT UPDATES. &lt;BR /&gt;&lt;BR /&gt;&lt;CODE class=""&gt;data want;

set have;

array rates[*] $12 rate1 - Rate6;
array k[*] $12 current_rate new_rate1 new_Rate2 new_rate3 new_RATE4 new_RATE5;

array ramt[*] amt1 - amt6; &lt;BR /&gt;array j[*] current_amt ramt1- ramt5;
do i=1 to dim(rates);

current_rate=rates{i];

current_rate_amt=ramt[i};

ind=i+1;

if rates[i]=current and rates[i] in ('A','T') then skip -- not sure how to do that???

do;

k[_ind]=rates[i];

j{_ind}=ramt[i];

end;

else

do;

k{i}=rates{i};

j{i}=ramt[i];

end;

end;

do i=1 to dim(j);

if j[i]=. then j[i]=0;

end;

drop i;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Dec 2021 22:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787194#M251472</guid>
      <dc:creator>bibbnd</dc:creator>
      <dc:date>2021-12-24T22:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787196#M251474</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I want to create all possible combinations from a row but selecting each rate as the current rate and than selecting the remaining rates in order from smallest to largests. I need to exclude the A or T rates when the current rate is going to be a D , 49, or 58. here is my original dataset group rate1 rate2 rate3 rate4 rate5 rate6 amt1 amt2 amt3 amt4 amt5 amt6 NNN T P 58 49 D A 2002 554 499 498 484 313 NNY T P D 49 58 A 1222 900 800 800 750 610 outcome dataset need: GROUP CURRENT RATE CURRENT AMT RATE1 AMT1 RATE2 AMT2 RATE3 AMT3 RATE4 AMT4 NNN D 484 49 498 58 498 P 554 NNN 49 498 D 484 58 499 P 554 NNN 58 499 D 484 49 498 P 554 NNN P 554 D 484 49 498 58 499 NNN A 610 D 484 49 498 58 499 P 554 NNN T 554 D 484 49 498 58 499 P 554 data test2; set test; array rates[*] $12 rate1 - Rate6; array k[*] $12 new_rate1 new_Rate2 new_rate3 new_RATE4 new_RATE5 new_rate6; array ramt[*] amt1 - amt6; array j[*] ramt1- ramt6; do i=1 to dim(rates); current_rate=rates{i]; current_rate_amt=ramt[i}; ind=i+1; if rates[i]=current and rates[i] in ('A','T') then skip -- not sure how to do that??? do; k[_ind]=rates[i]; j{_ind}=ramt[i]; end; else do; k{i}=rates{i}; j{i}=ramt[i]; end; end; do i=1 to dim(j); if j[i]=. then j[i]=0; end; drop i; run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can you reformat your post please? Don't forget to &lt;U&gt;use the appropriate icon for your code&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;And show the expected output.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 05:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787196#M251474</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-12-23T05:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787201#M251479</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149821"&gt;@bibbnd&lt;/a&gt;&amp;nbsp;, I edited your sample data to be more eaily read.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain your desired logic from there &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;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input group $ (rate1 - rate6)($) amt1 - amt6;
datalines; 
NNN T P 58 49 D  A 2002 554 499 498 484 313 
NNY T P D  49 58 A 1222 900 800 800 750 610 
;

data want;
input GROUP $ CURRENT_RATE $ CURRENT_AMT RATE1 $ AMT1 RATE2 $ AMT2 RATE3 $ AMT3 RATE4 $ AMT4;
infile datalines dlm = ',';
datalines;
NNN,  ,   ,D,484,49,498,58,498,P,554 
NNN,49,498,D,484,58,499,  ,   ,P,554 
NNN,58,499,D,484,49,498,  ,   ,P,554 
NNN,P ,554,D,484,49,498,58,499, ,    
NNN,A ,610,D,484,49,498,58,499,P,554 
NNN,T ,554,D,484,49,498,58,499,P,554 
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Dec 2021 07:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787201#M251479</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-12-23T07:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787208#M251484</link>
      <description>I need to logic to create the desired output. I want to select each rate as the current rate and than select the remaining rates from lowest to highest in that same row . Repeat this process within each row for each group until all rates have been given the current rate position. Once this is done, I do it again for the next group.&lt;BR /&gt;&lt;BR /&gt;Not sure why my sample data didn’t appear lined up.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Dec 2021 08:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787208#M251484</guid>
      <dc:creator>bibbnd</dc:creator>
      <dc:date>2021-12-23T08:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787209#M251485</link>
      <description>Didn’t know it posted in this manner.&lt;BR /&gt;What do you mean appropriate icon?&lt;BR /&gt;I will fix&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Dec 2021 08:34:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787209#M251485</guid>
      <dc:creator>bibbnd</dc:creator>
      <dc:date>2021-12-23T08:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787254#M251518</link>
      <description>&lt;P&gt;The forum editor has a tool bar with icons.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-12-23 112751.jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66941iE3A81E6EF076EA3A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-12-23 112751.jpg" alt="Screenshot 2021-12-23 112751.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;There is one for inserting text (Insert Code) and one for inserting SAS code (Insert SAS Code).&amp;nbsp; Use one of those buttons to get a pop-up window where you can paste (or edit) the lines of text or code you want to post.&amp;nbsp; Otherwise the forum considers what you type as words to be formatted into paragraphs.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 16:30:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787254#M251518</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-23T16:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787260#M251524</link>
      <description>I don't get any of those options when posting. I can't even edit the post to make it readable.</description>
      <pubDate>Thu, 23 Dec 2021 16:46:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787260#M251524</guid>
      <dc:creator>bibbnd</dc:creator>
      <dc:date>2021-12-23T16:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787265#M251526</link>
      <description>&lt;P&gt;What browser are you using to post your question? Your replies?&amp;nbsp; You should be typing into a box in the middle of the page.&amp;nbsp; Just above the box where you type is the menu bar.&amp;nbsp; Like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-12-23 120500.jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66943i7645C0A967860CFA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-12-23 120500.jpg" alt="Screenshot 2021-12-23 120500.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;To edit an old post you can click on the three vertical dots under your icon at the top of the post and select EDIT.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-12-23 120058.jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66942iBCD6BA3C5CB61086/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-12-23 120058.jpg" alt="Screenshot 2021-12-23 120058.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 17:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787265#M251526</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-23T17:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787270#M251531</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;data want;
input GROUP $ CURRENT_RATE $ CURRENT_AMT RATE1 $ AMT1 RATE2 $ AMT2 RATE3 $ AMT3 RATE4 $ AMT4 RATE5 $ AMT5;
infile datalines dlm = ',';
datalines;
NNN, D,484,49,498,58,498,P,554, ,
NNN,49,498,D,484,58,499, P,554, ,
NNN,58,499,D,484,49,498,P,554, ,  
NNN,P ,554,D,484,49,498,58,499, ,    
NNN,A ,610,D,484,49,498,58,499,P,554 
NNN,T ,554,D,484,49,498,58,499,P,554 
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;the reformatted version of my dataset is wrong, there is blanks and should not be there, the above code is the correct version of what i need&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 17:45:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787270#M251531</guid>
      <dc:creator>bibbnd</dc:creator>
      <dc:date>2021-12-23T17:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787335#M251560</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149821"&gt;@bibbnd&lt;/a&gt;&amp;nbsp;a few questions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The &lt;EM&gt;want&lt;/EM&gt; dataset code you supplied has more input variables (13) than values on your datalines (11). &lt;BR /&gt;Please correct this as your want dataset looks like this (lower dataset):&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AMSAS_0-1640345047676.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66950i03094404A3E73EFF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AMSAS_0-1640345047676.png" alt="AMSAS_0-1640345047676.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;Can you add the NNY group to the &lt;EM&gt;want&lt;/EM&gt; dataset. It might help us understand the logic that you are applying to transform the &lt;EM&gt;have&lt;/EM&gt; dataset to the &lt;EM&gt;want&lt;/EM&gt; dataset&lt;/LI&gt;
&lt;LI&gt;What is the rules/logic you apply to transform the &lt;EM&gt;have&lt;/EM&gt; dataset into the &lt;EM&gt;want&lt;/EM&gt; dataset&lt;BR /&gt;For example, why is the first observation in the &lt;EM&gt;want&lt;/EM&gt; dataset Current Rate D (D/484). it is neither the lowest rate (A/313) or Rate1 (T/2002)&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Dec 2021 11:41:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787335#M251560</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-12-24T11:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787372#M251576</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226241"&gt;@AMSAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I have fixed the want dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Add the the next group to the want dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. I rewrote my explanation in the first post to better layout the selection process.&amp;nbsp; There is no particular reason in setting the current rate. I just need each of the 6 rates to have a turn at being the current rate to create the 6 rows with each group.&amp;nbsp;&lt;/P&gt;&lt;P&gt;AS&amp;nbsp; I stated, i have been doing this manually for a long time because i have no luck at getting it coded.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Dec 2021 22:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787372#M251576</guid>
      <dc:creator>bibbnd</dc:creator>
      <dc:date>2021-12-24T22:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a lookup table from all possible group combination in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787399#M251589</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149821"&gt;@bibbnd&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below one way to go based on how I understand what you need. The code doesn't exactly create your desired outcome. I made the assumption this is due to some "typo" on your side when creating this data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input group $ (rate1 - rate6)($) amt1 - amt6;
  datalines;
NNN T P 58 49 D A 2002 554 499 498 484 313 
NNY T P D  49 58 A 1222 900 800 801 750 610 
;

data want;

  if _n_=1 then
    do;
      if 0 then set have(keep=group rate1 amt1 rename=(rate1=rate amt1=amt));
      dcl hash h1(ordered:'y',multidata:'y');
      h1.defineKey('amt');
      h1.defineData('group', 'rate', 'amt');
      h1.defineDone();
    end;
  call missing(of _all_);

  set have;

  /* load array elements into hash                    */
  /* - creates a long data structure sorted by amount */
  array a_rate {*} rate1 - rate6;
  array a_amt  {*} amt1 - amt6;
  do _i=1 to dim(a_rate);
    rate=a_rate[_i];
    amt=a_amt[_i];
    h1.add();
  end;

  /* read sorted data from hash into array and create permutations */
  dcl hiter hh1('h1');

  do _perm=1 to dim(a_rate);

    call missing(of a_rate[*], of a_amt[*]);
    _el=1;

    hh1.first();
    do _i=1 to dim(a_rate);
      if _i=_perm then
        do;
          a_rate[1]=rate;
          a_amt[1]=amt;
        end;
      else
      if rate not in ('A','T') then
        do;
          _el+1;
          a_rate[_el]=rate;
          a_amt[_el]=amt;
        end;

      if _i&amp;lt;dim(a_rate) then hh1.next();
    end;
    output;
  end;

  hh1.delete();
  h1.clear();

  drop rate amt _: ;

run;

data want;
  /* create desired column names and column order */
  length
    group $8
    rate1 $8 amt1 8
    rate2 $8 amt2 8
    rate3 $8 amt3 8
    rate4 $8 amt4 8
    rate5 $8 amt5 8
    rate6 $8 amt6 8
    ;
  rename
    rate1=current_rate amt1=current_amt
    rate2=rate1 amt2=amt1
    rate3=rate2 amt3=amt2
    rate4=rate3 amt4=amt3
    rate5=rate4 amt5=amt4
    rate6=rate5 amt6=amt5
    ;
  set want;
run;


data desired;
  infile datalines truncover dsd;
  input GROUP $ CURRENTrate $ CURRENTamt RATE1 $ AMT1 RATE2 $ AMT2 RATE3 $ AMT3 RATE4 $ AMT4 RATE5 $ AMT5;
  infile datalines dlm = ',';
  datalines;
NNN,D,484,49,498,58,498,P,554
NNN,49,498,D,484,58,499,P,554
NNN,58,499,D,484,49,498,P,554 
NNN,P,554,D,484,49,498,58,499   
NNN,A,610,D,484,49,498,58,499,P,554 
NNN,T,554,D,484,49,498,58,499,P,554 
NNY,T,1222,58,750,D,800,49,800,P,900
NNY,P,900,58,750,D,800,49,801
NNY,D,800,58,750,49,801,P,900
NNY,49,801,58,750,D,800,P,900 
NNY,58,750,D,800,49,801,P,901
NNY,A,610,58,750,D,800,49,801,P,900
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1640483030593.png" style="width: 674px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66963i54691A547AF07BB5/image-dimensions/674x251?v=v2" width="674" height="251" role="button" title="Patrick_0-1640483030593.png" alt="Patrick_0-1640483030593.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Dec 2021 01:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-lookup-table-from-all-possible-group-combination/m-p/787399#M251589</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-12-26T01:50:38Z</dc:date>
    </item>
  </channel>
</rss>

