<?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: Function that outputs attribute name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188578#M35644</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: #000000;"&gt;HI..&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: #000000;"&gt;For the above query,I have a slight modification in the requirement in case of ties.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: #000000;"&gt;Sample dataset:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN style="font-size: 10pt; color: #000000;"&gt;Cust_ID,MCG_1,MCG_2,MCG_3,MCG_4,MCG_5,MCG_6,MCG_7,MCG_8,MCG_9,MCG_10,MCG_11,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: #000000;"&gt;Sp_1, Sp_2, Sp_3, Sp_4, Sp_5, Sp_6, Sp_7, Sp_8, Sp_9, Sp_10, Sp_11,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; font-size: 10pt;"&gt;3478,2.5,2.5,2.5,9.5,9.5,8,.,2.5,5.5,7,5.5,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000,11000,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; font-size: 10pt;"&gt;3479,1.5,3.5,3.5,8.5,8.5,10,11,1.5,6,6,6,15000,14000,12500,11000,9000,8000,7500,15000,6000,5000,4000&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;The 11 attributes MCG_1 to MCG_11 are row wise ranks based on customer RFM scores in 11 merchant category groups(Shopping/Restaurants etc) and sp_1 to sp_11 their respective spends($)&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;The codes shared by Tom &amp;amp; Arthur helped me create 11 new variables which gave me variable names based on their ranks;and both the variable names in case of ties.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;In case of ties,instead of&amp;nbsp; tied variable names separted by '/ ' I now want the variable name of the Max value of corresponding tied spends.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;Earlier outcome was:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 995px;" summary="Page Layout"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" height="20" width="53"&gt;Cust_ID&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="201"&gt;rank1&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="41"&gt;rank2&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="96"&gt;rank3&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="41"&gt;rank4&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="165"&gt;rank5&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="41"&gt;rank6&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="57"&gt;rank7&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="100"&gt;rank8&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="100"&gt;rank9&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="50"&gt;rank10&lt;/TD&gt;&lt;TD class="xl68" style="border-left: none;" width="50"&gt;rank11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl69" height="20" style="border-top: none;" width="53"&gt;3478&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="201"&gt;MCG_1/MCG_2/MCG_3/MCG_8&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="96"&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="165"&gt;MCG_9/MCG_11&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="57"&gt;MCG_10&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="100"&gt;MCG_6&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="100"&gt;MCG_4/MCG_5&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="50"&gt;&lt;/TD&gt;&lt;TD class="xl70" style="border-top: none; border-left: none;" width="50"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="21" style="border-top: none;" width="53"&gt;3479&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="201"&gt;MCG_1/MCG_8&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="96"&gt;MCG_2/MCG_3&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="165"&gt;MCG_9/MCG_10/MCG_11&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;" width="57"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="100"&gt;MCG_4/MCG_5&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;" width="100"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="50"&gt;MCG_6&lt;/TD&gt;&lt;TD align="left" class="xl73" style="border-top: none; border-left: none;" width="50"&gt;MCG_7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;Required outcome:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 638px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" height="20" width="52"&gt;Cust_ID&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank1&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank2&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank3&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank4&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank5&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank6&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank7&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank8&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank9&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="59"&gt;rank10&lt;/TD&gt;&lt;TD class="xl68" style="border-left: none;" width="59"&gt;rank11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl69" height="24" style="border-top: none;" width="52"&gt;3478&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_8&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_3&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_2&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_1&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_11&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_9&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;MCG_10&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;MCG_6&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_5&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="59"&gt;sp_4&lt;/TD&gt;&lt;TD class="xl70" style="border-top: none; border-left: none;" width="59"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="21" style="border-top: none;" width="52"&gt;3479&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_1&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_8&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_2&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_3&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_9&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_10&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_11&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_4&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_5&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="59"&gt;MCG_6&lt;/TD&gt;&lt;TD align="left" class="xl73" style="border-top: none; border-left: none;" width="59"&gt;MCG_7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;In 2nd record,MCG(1 &amp;amp; &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; as well as Sp variable is tied for rank 1.Either of the variable name sp_1 or sp_8 will be acceptable in rank1 &amp;amp; rank2 values. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;Can this be done in SAS?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Mar 2014 14:20:56 GMT</pubDate>
    <dc:creator>Shalini_K</dc:creator>
    <dc:date>2014-03-06T14:20:56Z</dc:date>
    <item>
      <title>Function that outputs attribute name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188572#M35638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;My data set has following fields&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Customer_ID(Primary key)&amp;nbsp; MCG_1&amp;nbsp; MCG_2&amp;nbsp; MCG_3&amp;nbsp;&amp;nbsp; MCG_4&amp;nbsp;&amp;nbsp; MCG_5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;The 5 attributes MCG_1 to MCG_5 are row wise ranks based on customer spends in 5 merchant category groups(Shopping/Restaurants etc) also&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;containing ties and blanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Sample dataset:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Cust_ID,MCG_1,MCG_2,MCG_3,MCG_4,MCG_5,&lt;/P&gt;&lt;P&gt;3589,2,5,1,3,4,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;1366,1.5,1.5,4,3,5,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;6144,,1,2,4,3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;I need to create 5 variables in the dataset which will give me variable names based on their ranks;and both the variable names in case of ties(eg 2nd record below)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;How can I do it in Base SAS ?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Helvetica, sans-serif; font-size: 10pt; line-height: 1.5em;"&gt;Intended outcome:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="420"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl70" height="20" width="64"&gt;Cust_ID&lt;/TD&gt;&lt;TD class="xl71" width="100"&gt;Rank1&lt;/TD&gt;&lt;TD class="xl71" width="64"&gt;Rank2&lt;/TD&gt;&lt;TD class="xl71" width="64"&gt;Rank3&lt;/TD&gt;&lt;TD class="xl71" width="64"&gt;Rank4&lt;/TD&gt;&lt;TD class="xl72" width="64"&gt;Rank5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;3589&lt;/TD&gt;&lt;TD&gt;MCG_3&lt;/TD&gt;&lt;TD&gt;MCG_1&lt;/TD&gt;&lt;TD&gt;MCG_4&lt;/TD&gt;&lt;TD&gt;MCG_5&lt;/TD&gt;&lt;TD class="xl66"&gt;MCG_2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;1366&lt;/TD&gt;&lt;TD&gt;MCG_1/MCG_2&lt;/TD&gt;&lt;TD&gt; &lt;/TD&gt;&lt;TD&gt;MCG_4&lt;/TD&gt;&lt;TD&gt;MCG_3&lt;/TD&gt;&lt;TD class="xl66"&gt;MCG_5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20"&gt;6144&lt;/TD&gt;&lt;TD class="xl68"&gt;MCG_2&lt;/TD&gt;&lt;TD class="xl68"&gt;MCG_3&lt;/TD&gt;&lt;TD class="xl68"&gt;MCG_5&lt;/TD&gt;&lt;TD class="xl68"&gt;MCG_4&lt;/TD&gt;&lt;TD class="xl69"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Shalini&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Jan 2014 19:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188572#M35638</guid>
      <dc:creator>Shalini_K</dc:creator>
      <dc:date>2014-01-05T19:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Function that outputs attribute name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188573#M35639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think that the following will do what you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=MCG_1-MCG_5);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array _r(*) MCG_1-MCG_5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array rank(5) $11.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing (of rank(*));&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _n_=1 to dim(_r);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not missing(_r(_n_)) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if int(_r(_n_)) eq _r(_n_) then rank(_r(_n_))=vname(_r(_n_));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if missing(rank(int(_r(_n_)))) then rank(int(_r(_n_)))=&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vname(_r(int(_r(_n_))));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&amp;nbsp; rank(int(_r(_n_)))=catx('/',rank(int(_r(_n_))),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vname(_r(_n_)));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Jan 2014 21:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188573#M35639</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-01-05T21:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Function that outputs attribute name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188574#M35640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Arthur for your help..&lt;/P&gt;&lt;P&gt;When I increased the attributes from 5 to 11, the code provides incorrect output in case of ties.&lt;/P&gt;&lt;P&gt;For eg:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Cust_ID,MCG_1,MCG_2,MCG_3,MCG_4,MCG_5,&lt;/SPAN&gt;MCG_6,MCG_7,MCG_8,MCG_9,MCG_10,MCG_11,&lt;/P&gt;&lt;P&gt;3478,2.5,2.5,2.5,9.5,9.5,8,,2.5,5.5,7,5.5&lt;/P&gt;&lt;P&gt;the code gives below output:&lt;/P&gt;&lt;P&gt;Rank1-(blank), Rank2- MCG_2/MCG_2/MCG_3/MCG_8&lt;/P&gt;&lt;P&gt;Rank3-(blank), Rank4- (blank), &lt;/P&gt;&lt;P&gt;Rank5 - MCG_5/MCG_11, Rank6 - (blank),&lt;/P&gt;&lt;P&gt;Rank7 - MCG_10,&amp;nbsp; Rank8 - MCG_6,&lt;/P&gt;&lt;P&gt;Rank9 -MCG_9/MCG_5 , Rank10 - (blank),&amp;nbsp; Rank11 - (blank)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The required outcome is:&lt;/P&gt;&lt;P&gt;Rank1 - (MCG_1/MCG_2/MCG_3/MCG_8 , Rank2- (blank),&lt;/P&gt;&lt;P&gt;Rank3-(blank), Rank4- (blank), &lt;/P&gt;&lt;P&gt;Rank5 - MCG_9/MCG_11, Rank6 - (blank),&lt;/P&gt;&lt;P&gt;Rank7 - MCG_10,&amp;nbsp; Rank8 - MCG_6,&amp;nbsp; &lt;/P&gt;&lt;P&gt;Rank9 -MCG_4/MCG_5 , Rank10 - (blank),&amp;nbsp; Rank11 - (blank)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What can be done to achieve the required outcome?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jan 2014 18:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188574#M35640</guid>
      <dc:creator>Shalini_K</dc:creator>
      <dc:date>2014-01-06T18:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Function that outputs attribute name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188575#M35641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Restructure data using PROC TRANSPOSE and then use PROC RANK TIES=LOW to convert your ranks into integers that you can use as array indexes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data have ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; infile cards dsd truncover ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input Cust_ID MCG_1 - MCG_11 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;3589,2,5,1,3,4,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;1366,1.5,1.5,4,3,5,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;6144,,1,2,4,3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;3478,2.5,2.5,2.5,9.5,9.5,8,.,2.5,5.5,7,5.5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc transpose data=have out=vertical ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by cust_id notsorted;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var mcg_: ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc rank data=vertical ties=low out=vertical2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by cust_id notsorted;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var col1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ranks rank;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set vertical2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by cust_id notsorted;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; array r $100 rank1-rank11 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; retain rank1-rank11;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; keep cust_id rank1-rank11;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if first.cust_id then call missing(of rank1-rank11);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if rank then r(rank)=catx('/',r(rank),_name_);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if last.cust_id ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put (_all_) (=/);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Cust_ID=3589&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank1=MCG_3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank2=MCG_1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank3=MCG_4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank4=MCG_5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank5=MCG_2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank6=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank7=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank8=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank9=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank10=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank11=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Cust_ID=1366&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank1=MCG_1/MCG_2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank2=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank3=MCG_4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank4=MCG_3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank5=MCG_5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank6=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank7=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank8=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank9=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank10=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank11=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Cust_ID=6144&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank1=MCG_2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank2=MCG_3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank3=MCG_5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank4=MCG_4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank5=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank6=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank7=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank8=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank9=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank10=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank11=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Cust_ID=3478&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank1=MCG_1/MCG_2/MCG_3/MCG_8&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank2=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank3=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank4=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank5=MCG_9/MCG_11&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank6=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank7=MCG_10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank8=MCG_6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank9=MCG_4/MCG_5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank10=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rank11=&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jan 2014 19:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188575#M35641</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-01-06T19:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: Function that outputs attribute name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188576#M35642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You would have to test the following, but I think it does what you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile cards dlm=',';&lt;/P&gt;&lt;P&gt;&amp;nbsp; input Cust_ID MCG_1-MCG_11;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;3478,2.5,2.5,2.5,9.5,9.5,8,.,2.5,5.5,7,5.5&lt;/P&gt;&lt;P&gt;3479,1.5,3.5,3.5,8.5,8.5,10,11,1.5,6,6,6&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want (drop=MCG: counter: _: i j);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array r(*) MCG_1-MCG_11;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array rank(11) $70.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array counter(11);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array _rank(11);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing (of rank(*));&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing (of counter(*));&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing (of _rank(*));&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 11;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not missing(r(i)) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j=1 to 11;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if r(i)=r(j) then counter(i)+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if counter(i) eq 1 then _rank(i)=r(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else _rank(i)=round(r(i))-(int(counter(i)/2));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to dim(r);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not missing(r(i)) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if r(i) eq _rank(i) then rank(r(i))=vname(r(i));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&amp;nbsp; rank(_rank(i))=catx('/',rank(_rank(i)),vname(r(i)));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jan 2014 22:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188576#M35642</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-01-06T22:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Function that outputs attribute name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188577#M35643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot..Both the codes worked for me&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jan 2014 18:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188577#M35643</guid>
      <dc:creator>Shalini_K</dc:creator>
      <dc:date>2014-01-08T18:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Function that outputs attribute name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188578#M35644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: #000000;"&gt;HI..&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: #000000;"&gt;For the above query,I have a slight modification in the requirement in case of ties.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: #000000;"&gt;Sample dataset:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN style="font-size: 10pt; color: #000000;"&gt;Cust_ID,MCG_1,MCG_2,MCG_3,MCG_4,MCG_5,MCG_6,MCG_7,MCG_8,MCG_9,MCG_10,MCG_11,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: #000000;"&gt;Sp_1, Sp_2, Sp_3, Sp_4, Sp_5, Sp_6, Sp_7, Sp_8, Sp_9, Sp_10, Sp_11,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; font-size: 10pt;"&gt;3478,2.5,2.5,2.5,9.5,9.5,8,.,2.5,5.5,7,5.5,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000,11000,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; font-size: 10pt;"&gt;3479,1.5,3.5,3.5,8.5,8.5,10,11,1.5,6,6,6,15000,14000,12500,11000,9000,8000,7500,15000,6000,5000,4000&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;The 11 attributes MCG_1 to MCG_11 are row wise ranks based on customer RFM scores in 11 merchant category groups(Shopping/Restaurants etc) and sp_1 to sp_11 their respective spends($)&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;The codes shared by Tom &amp;amp; Arthur helped me create 11 new variables which gave me variable names based on their ranks;and both the variable names in case of ties.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;In case of ties,instead of&amp;nbsp; tied variable names separted by '/ ' I now want the variable name of the Max value of corresponding tied spends.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;Earlier outcome was:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 995px;" summary="Page Layout"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" height="20" width="53"&gt;Cust_ID&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="201"&gt;rank1&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="41"&gt;rank2&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="96"&gt;rank3&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="41"&gt;rank4&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="165"&gt;rank5&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="41"&gt;rank6&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="57"&gt;rank7&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="100"&gt;rank8&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="100"&gt;rank9&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="50"&gt;rank10&lt;/TD&gt;&lt;TD class="xl68" style="border-left: none;" width="50"&gt;rank11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl69" height="20" style="border-top: none;" width="53"&gt;3478&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="201"&gt;MCG_1/MCG_2/MCG_3/MCG_8&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="96"&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="165"&gt;MCG_9/MCG_11&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="57"&gt;MCG_10&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="100"&gt;MCG_6&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="100"&gt;MCG_4/MCG_5&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="50"&gt;&lt;/TD&gt;&lt;TD class="xl70" style="border-top: none; border-left: none;" width="50"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="21" style="border-top: none;" width="53"&gt;3479&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="201"&gt;MCG_1/MCG_8&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="96"&gt;MCG_2/MCG_3&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="165"&gt;MCG_9/MCG_10/MCG_11&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;" width="41"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;" width="57"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="100"&gt;MCG_4/MCG_5&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none; border-left: none;" width="100"&gt;&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="50"&gt;MCG_6&lt;/TD&gt;&lt;TD align="left" class="xl73" style="border-top: none; border-left: none;" width="50"&gt;MCG_7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;Required outcome:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 638px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" height="20" width="52"&gt;Cust_ID&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank1&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank2&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank3&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank4&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank5&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank6&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank7&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank8&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="52"&gt;rank9&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="59"&gt;rank10&lt;/TD&gt;&lt;TD class="xl68" style="border-left: none;" width="59"&gt;rank11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl69" height="24" style="border-top: none;" width="52"&gt;3478&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_8&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_3&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_2&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_1&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_11&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_9&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;MCG_10&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;MCG_6&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="52"&gt;sp_5&lt;/TD&gt;&lt;TD align="left" class="xl65" style="border-top: none; border-left: none;" width="59"&gt;sp_4&lt;/TD&gt;&lt;TD class="xl70" style="border-top: none; border-left: none;" width="59"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="21" style="border-top: none;" width="52"&gt;3479&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_1&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_8&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_2&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_3&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_9&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_10&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_11&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_4&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="52"&gt;sp_5&lt;/TD&gt;&lt;TD align="left" class="xl72" style="border-top: none; border-left: none;" width="59"&gt;MCG_6&lt;/TD&gt;&lt;TD align="left" class="xl73" style="border-top: none; border-left: none;" width="59"&gt;MCG_7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;In 2nd record,MCG(1 &amp;amp; &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; as well as Sp variable is tied for rank 1.Either of the variable name sp_1 or sp_8 will be acceptable in rank1 &amp;amp; rank2 values. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;Can this be done in SAS?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffff; font-family: Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Mar 2014 14:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188578#M35644</guid>
      <dc:creator>Shalini_K</dc:creator>
      <dc:date>2014-03-06T14:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Function that outputs attribute name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188579#M35645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The 'earlier outcome' &amp;amp; 'required outcome' tables have 20+ columns &amp;amp; may not appear totally on the screen.Hence,I am attaching a csv file&lt;/P&gt;&lt;P&gt;'Reqd_Outcome.csv' for your reference.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Mar 2014 14:31:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-that-outputs-attribute-name/m-p/188579#M35645</guid>
      <dc:creator>Shalini_K</dc:creator>
      <dc:date>2014-03-06T14:31:09Z</dc:date>
    </item>
  </channel>
</rss>

