<?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: Array leaders in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507588#M1471</link>
    <description>SAS works better with long data, so I would transform to a long format. For #1 I'd run a proc freq and get the Counts/labels for variables where the percentages is the highest. You can use ORDER=FREQ to ensure the highest count is first. &lt;BR /&gt;&lt;BR /&gt;I have no idea what #2 is asking or means. &lt;BR /&gt;&lt;BR /&gt;An 'array' in SAS is different than many other languages, it's just a shortcut reference to other variables. If you want to do array/matrix type manipulations you could consider IML which is closer to R/Python. &lt;BR /&gt;</description>
    <pubDate>Thu, 25 Oct 2018 21:12:33 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-10-25T21:12:33Z</dc:date>
    <item>
      <title>Array leaders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507563#M1462</link>
      <description>&lt;P&gt;I am taking this from a website "Codility"&amp;nbsp;that tests computer programmers in languages other than SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Array leader&lt;/EM&gt; is an element that happens in more than half an array.&lt;/P&gt;&lt;P&gt;1.) How would you find an array leader using SAS? If it doesn't exist, please return -1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Equi leader&lt;/EM&gt; is an array leader that is shared between two parts of the same array, split on one of the elements.&lt;/P&gt;&lt;P&gt;2.) How would you count the number of equi leaders in an array using SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 20:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507563#M1462</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-10-25T20:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Array leaders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507568#M1463</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/235176"&gt;@pink_poodle&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am taking this from a website "Codility"&amp;nbsp;that tests computer programmers in languages other than SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Array leader&lt;/EM&gt; is an element that happens in more than half an array.&lt;/P&gt;
&lt;P&gt;1.) How would you find an array leader using SAS? If it doesn't exist, please return -1.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Return what otherwise?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Equi leader&lt;/EM&gt; is an array leader that is shared between two parts of the same array, split on one of the elements.&lt;/P&gt;
&lt;P&gt;2.) How would you count the number of equi leaders in an array using SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you may need to provide a bit more of an example as "split on one of the elements" doesn't mean anything obvious to me.&lt;/P&gt;
&lt;P&gt;And since you are saying "two parts" of the same array, how do you define a "part" of the same array?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 20:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507568#M1463</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-25T20:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Array leaders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507588#M1471</link>
      <description>SAS works better with long data, so I would transform to a long format. For #1 I'd run a proc freq and get the Counts/labels for variables where the percentages is the highest. You can use ORDER=FREQ to ensure the highest count is first. &lt;BR /&gt;&lt;BR /&gt;I have no idea what #2 is asking or means. &lt;BR /&gt;&lt;BR /&gt;An 'array' in SAS is different than many other languages, it's just a shortcut reference to other variables. If you want to do array/matrix type manipulations you could consider IML which is closer to R/Python. &lt;BR /&gt;</description>
      <pubDate>Thu, 25 Oct 2018 21:12:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507588#M1471</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-25T21:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Array leaders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507603#M1480</link>
      <description>&lt;P&gt;1) For example, if one variable stores array sequences, like 123456, and the other variable -&amp;nbsp;their leaders. This 123456 array will not have a leader, so the leader variable should default to (-1).&lt;BR /&gt;&lt;BR /&gt;2) I will put this answer in a&amp;nbsp;separate response.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 22:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507603#M1480</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-10-25T22:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Array leaders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507604#M1481</link>
      <description>&lt;P&gt;Here is a clarification about &lt;EM&gt;equi leaders&lt;/EM&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Keeping in mind that a&amp;nbsp;leader, simply put,&amp;nbsp;is the most popular element in an array,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if we have an array&amp;nbsp;434442, the overall leader is 4.&lt;/P&gt;&lt;P&gt;The questions is, how many times will we come across &lt;EM&gt;equi leaders&lt;/EM&gt; in this array?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To find out, we&amp;nbsp;split the array sequentially like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) 4 (leader = &lt;FONT color="#ff0000"&gt;4&lt;/FONT&gt;)&amp;nbsp; and&amp;nbsp;34442 (leader =&lt;FONT color="#ff0000"&gt; 4&lt;/FONT&gt;) ----------&amp;gt; bingo! first instance of an equi leader&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2)&amp;nbsp;43 (leader = -1, i.e., not there) and&amp;nbsp;4442 (leader = 4)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3)&amp;nbsp; 434&amp;nbsp;(leader =&amp;nbsp;&lt;FONT color="#ff0000"&gt;4&lt;/FONT&gt;) and&amp;nbsp;442 (leader = &lt;FONT color="#ff0000"&gt;4&lt;/FONT&gt;)&amp;nbsp; ---------&amp;gt; bingo! second instance of an equi leader&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4)&amp;nbsp;4344 (leader = 4) and&amp;nbsp;42 (leader = -1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5) 11223 (leader = -1) and 3 (leader = 3)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, the count of equi leaders is 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Reference&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://app.codility.com/programmers/lessons/8-leader/" target="_self"&gt;Codility Lesson 8: Leaders&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 22:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507604#M1481</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-10-25T22:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Array leaders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507608#M1482</link>
      <description>I agree, it is not as straight-forward to do array slices, like Python list slices.</description>
      <pubDate>Thu, 25 Oct 2018 22:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507608#M1482</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-10-25T22:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Array leaders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507613#M1484</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/235176"&gt;@pink_poodle&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;1) For example, if one variable stores array sequences, like 123456, and the other variable -&amp;nbsp;their leaders. This 123456 array will not have a leader, so the leader variable should default to (-1).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But you have &lt;STRONG&gt;not&lt;/STRONG&gt; answered what the value should be if there&lt;STRONG&gt; is&lt;/STRONG&gt; a "leader".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note SAS arrays consist of a number of variables so I cannot actually map a single string like 123456 to an array as that appears to be a single element. With a single element then the most common value is the ONLY value. If you mean to imply that is a number of variables that each hold a single digit then that may makes a little more sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This link has one way to find a MODE value of an array in SAS, mode being the most frequent value. However for your "leader" approach you need some additional code to check if the mode actually represents more than a single value&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 22:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507613#M1484</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-25T22:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Array leaders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507631#M1493</link>
      <description>It is an interesting idea about the mode. I think you forgot to attach the link.</description>
      <pubDate>Fri, 26 Oct 2018 02:38:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507631#M1493</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-10-26T02:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: Array leaders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507635#M1495</link>
      <description>PROC UNIVARIATE calculates the mode. I think there's an example in the documentation. But...that means your data is transpose to a long format.</description>
      <pubDate>Fri, 26 Oct 2018 02:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Array-leaders/m-p/507635#M1495</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-26T02:47:27Z</dc:date>
    </item>
  </channel>
</rss>

