<?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 Generating Random Letters in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491158#M73298</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a script that opens data set where I have a list of "Operator". I have to manually assign each person a random letter in the "Analyst"&amp;nbsp; but wondering if there is a&amp;nbsp; code that could loop though all the different operators and assign a random letter to the analyst column?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="B1234_0-1653378889551.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/42661iF158CB03F484899E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="B1234_0-1653378889551.png" alt="B1234_0-1653378889551.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:48:51 GMT</pubDate>
    <dc:creator>B1234</dc:creator>
    <dc:date>2023-06-10T23:48:51Z</dc:date>
    <item>
      <title>Generating Random Letters</title>
      <link>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491158#M73298</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a script that opens data set where I have a list of "Operator". I have to manually assign each person a random letter in the "Analyst"&amp;nbsp; but wondering if there is a&amp;nbsp; code that could loop though all the different operators and assign a random letter to the analyst column?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="B1234_0-1653378889551.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/42661iF158CB03F484899E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="B1234_0-1653378889551.png" alt="B1234_0-1653378889551.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:48:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491158#M73298</guid>
      <dc:creator>B1234</dc:creator>
      <dc:date>2023-06-10T23:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Random Letters</title>
      <link>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491187#M73299</link>
      <description>&lt;P&gt;Here's one way. Note that 'RandomShuffle()' assures you don't assign the same letter more than once (which I assume is what you need):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

// List of possible values
letterList = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};

// Number of rows in data table
n = 10;

// Values to assign to new character column
colVals = letterList[RandomShuffle(1::n)];

Print(colVals);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 08:35:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491187#M73299</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2022-05-24T08:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Random Letters</title>
      <link>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491218#M73300</link>
      <description>&lt;P&gt;Thanks, how do I account for the same operator name. I would have multiple rows where initials are "ABC" so I want all of these to be the same random letter?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NamesDefaultToHere(1);&lt;/P&gt;&lt;P&gt;dt=new table();&lt;BR /&gt;dt&amp;lt;&amp;lt;addrows(100);&lt;BR /&gt;dt&amp;lt;&amp;lt;new column("Operator", character, set values ({"ABC", "ABC", "DEF", "GHI"}));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// List of possible values&lt;BR /&gt;letterList = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};&lt;/P&gt;&lt;P&gt;// Number of rows in data table&lt;BR /&gt;n = 10;&lt;/P&gt;&lt;P&gt;// Values to assign to new character column&lt;BR /&gt;colVals = letterList[RandomShuffle(1::n)];&lt;/P&gt;&lt;P&gt;Print(colVals);&lt;/P&gt;&lt;P&gt;dt&amp;lt;&amp;lt;new column ("Analyst", character,set values(colVals));&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 09:36:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491218#M73300</guid>
      <dc:creator>B1234</dc:creator>
      <dc:date>2022-05-24T09:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Random Letters</title>
      <link>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491250#M73301</link>
      <description>&lt;P&gt;One option would be to use &lt;A href="https://www.jmp.com/support/help/en/16.2/#page/jmp/associative-arrays.shtml#" target="_blank" rel="noopener"&gt;associative array&lt;/A&gt; in combination with&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3605"&gt;@ian_jmp&lt;/a&gt;&amp;nbsp;solution. Something like this could work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("test",
	addrows(100),
	New Column("Operator", character, set values({"ABC", "ABC", "DEF", "GHI"}));
);

// List of possible values
letterList = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};

uniq_oper = Associative Array(dt:Operator) &amp;lt;&amp;lt; get keys;
Remove From(uniq_oper, Contains(uniq_oper, "")); // remove missing
uniq_oper_letter = letterList[Random Shuffle(1::N Items(letterList))][1::N Items(uniq_oper)];

oper_aa = Associative Array(uniq_oper, uniq_oper_letter);

dt &amp;lt;&amp;lt; New Column("Analyst", character, &amp;lt;&amp;lt; Set Each Value(
	If(Contains(oper_aa, :Operator),
		oper_aa[:Operator]
	,
		""
	)
));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 May 2022 10:06:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491250#M73301</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-05-24T10:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Random Letters</title>
      <link>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491359#M73304</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3605"&gt;@ian_jmp&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp; you both make this seem so easy! thank you both for your help :D&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 12:51:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Generating-Random-Letters/m-p/491359#M73304</guid>
      <dc:creator>B1234</dc:creator>
      <dc:date>2022-05-24T12:51:28Z</dc:date>
    </item>
  </channel>
</rss>

