<?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: Equally assign a list of values to another list of values by their respective Group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484262#M125709</link>
    <description>&lt;P&gt;The algorithm relies on the groups being the same in both sets.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Aug 2018 05:14:12 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-08-06T05:14:12Z</dc:date>
    <item>
      <title>Equally assign a list of values to another list of values by their respective Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484233#M125692</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Typically there's a lead generation listing for marketing campaigns, let's say 10000 customers of marketing lead, each with different grouping.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say 5000&amp;nbsp;customers with Group A, 2000 records with Group B and 3000 records with Group C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have&lt;/P&gt;&lt;P&gt;custID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; group&lt;/P&gt;&lt;P&gt;ABC123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DEF456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;GHI789&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;JKL101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;MNO112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;F000131&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;G000415&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each of the group has its own group of staffs to be equally assigned to for telemarketing&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;staff&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; group&lt;/P&gt;&lt;P&gt;John&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; A&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Paul&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; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sartre&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Richard&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Olsen&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Lykke&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Chuck&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Norris&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any function that allows me to equally assign the 10,000 customers to the list of staff by their group?&lt;/P&gt;&lt;P&gt;Want table is as below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;custID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; group&amp;nbsp; &amp;nbsp;staff&lt;/P&gt;&lt;P&gt;ABC123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp;Jean&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DEF456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; Paul&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;GHI789&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&amp;nbsp; &amp;nbsp;Chuck&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;JKL101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; Sartre&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;MNO112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp;Richard&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;F000131&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp;Olsen&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;G000415&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C Norris&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;IJUIJ122&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A Jean&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;YHU1232&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A Paul&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 03:30:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484233#M125692</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T03:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484234#M125693</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;prospect_custID group
1                        A
2                        A
3                        C
4                        A
5                        B
6                        B
7                        C

proc sort data=have;
by group;
run;

data want;
set have;
by group;
retain personnel_ID;
if first.group then personnel_id=1;
else personnel_id+1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Aug 2018 02:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484234#M125693</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-06T02:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484235#M125694</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/126418"&gt;@jaga&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;The last data step, how does you refer the personnel_ID as it's from another table?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 06 Aug 2018 02:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484235#M125694</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T02:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484236#M125695</link>
      <description>I've updated the table, unfortunately the personnel_id is not a running number as your assumption.</description>
      <pubDate>Mon, 06 Aug 2018 02:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484236#M125695</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T02:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484237#M125696</link>
      <description>you mean to say the personnel_ID is coming from another dataset. I did not understand your question, in the main dataset we have prospect_custID, which has difference numbers for each group. Could you please  give more details</description>
      <pubDate>Mon, 06 Aug 2018 02:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484237#M125696</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-06T02:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484238#M125697</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/141869"&gt;@t30&lt;/a&gt;, Your question isn't clear to me and if you don't mind, please elaborate.&lt;/P&gt;
&lt;P&gt;are your data in sas datasets?If yes,&lt;/P&gt;
&lt;P&gt;How many?&lt;/P&gt;
&lt;P&gt;what data is stored in those corresponding data-sets?a clear sample will help&lt;/P&gt;
&lt;P&gt;what's the primary one and what are the look up ones?&lt;/P&gt;
&lt;P&gt;And then explain your requirement with logic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May be there are very smart people who can comprehend from what you wrote, but I am afraid I am definitely not that kind. So if you may, please.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 02:16:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484238#M125697</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-06T02:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484239#M125698</link>
      <description>yes, basically I want to equally distribute the 10,000 records to a list of staff.</description>
      <pubDate>Mon, 06 Aug 2018 02:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484239#M125698</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T02:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484240#M125699</link>
      <description>Hi sorry, let me rephrase it</description>
      <pubDate>Mon, 06 Aug 2018 02:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484240#M125699</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T02:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484242#M125700</link>
      <description>&lt;P&gt;Do we have to assume the look up is exactly in sequence as your sample suggests? meaning&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;JKL101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/STRONG&gt; is the 3rd in A sequence in table HAVE and does it match 3rd in sequence in look up table&amp;nbsp;&lt;STRONG&gt;Sartre&amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In essence is it a sequence based match within groups?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, it causes ambiguity as the question arises why can't&amp;nbsp;&lt;SPAN&gt;ABC123&amp;nbsp; be he id of staff sartre?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 02:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484242#M125700</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-06T02:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484244#M125701</link>
      <description>&lt;P&gt;Nope, it can be as random, as long as in the end, the 10,000 customers will be equally assigned to the staff based on their group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But of course, if you follow by sequence, the customers will still be equally assign.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In a simpler example, let's say I have 10,000 customers, how do I equally assign these 10,000 customers to 10 staffs?&lt;/P&gt;&lt;P&gt;If there's a uniform distribution assignment, we can expect each staff to receive around 1000 customers each.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I do this in SAS data step? To complicate things, each customer and staff have their own group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 03:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484244#M125701</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T03:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484246#M125702</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by group;
run;

data want;
set have;
by group;
retain sort+id;
if first.group then sort_id=1;
else sort_id+1;
run;


dataset A;
personnel_ID              group
A1557800                        A
B1344223                        A
C1233423                        A

Dataset B;
personnel_ID group
A1235623                        B
B1789234                        B
C1909892                        B

Dataset C;
 personnel_ID            group
A1234323                        C
B8989132                        C
C4234234                        C


Data ABC;
Set A B C;
Run;

Proc sort data=abc;
By group;
Run;

Data abc2;
set abc;
by group;
retain sort_id;
if first.group then sort_id=1;
else sort_id +1;
run;

proc sort data=want;
by group sort_id;
run;

proc sort data=abc2;
by group sort_id;
run;

data all;
merge abc2 want;
by group sort_id;
run;






&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Aug 2018 03:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484246#M125702</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-06T03:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Equally assign a list of values to another list of values by their respective Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484248#M125703</link>
      <description>&lt;P&gt;You could use an array to do random assignment within groups:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
input custID $ group $;
datalines;
ABC123                    A
DEF456                    A
GHI789                     C
JKL101                      A
MNO112                   B
F000131                   B
G000415                   C
;
data staff;
input staff $ group $;
datalines;
John                          A
Paul                          A
Sartre                        A
Richard                     B
Olsen                        B
Lykke                        B
Chuck                        C
Norris                        C
;

data temp;
set have;
rnd = rand("uniform");
run;

proc sort data=temp; by group rnd; run;
proc sort data=staff; by group; run;

%let staffCount=100; /* Larger than any group staff count */

data want;
array s{&amp;amp;staffCount} $8 _temporary_;

do n = 1 by 1 until(last.group);
    set staff; by group;
    s{n} = staff;
    end;

do i = 1 by 1 until(last.group);
    set temp; by group;
    staff = s{1 + mod(i, n)};
    output;
    end;
keep custID group staff;

run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Aug 2018 03:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484248#M125703</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-08-06T03:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Mapping a list of values to another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484259#M125706</link>
      <description>Hi Jag, I think the latter part doesn't work. PG reply works for his 2 test tables though, at least you can get the idea from there</description>
      <pubDate>Mon, 06 Aug 2018 04:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484259#M125706</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T04:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Equally assign a list of values to another list of values by their respective Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484261#M125708</link>
      <description>Hi PG, any reason why if some groups don't exist in the either table, the array assignment above will no longer work?&lt;BR /&gt;&lt;BR /&gt;For example in my staff table, there are some staffs with no group, so the default value is blank as in ''.&lt;BR /&gt;Some staffs have Group Z but Group Z is not part of the customer table.&lt;BR /&gt;&lt;BR /&gt;Your array assignment works only if the groups are present in both tables. Is there any way to avoid such assumption?</description>
      <pubDate>Mon, 06 Aug 2018 04:59:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484261#M125708</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T04:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Equally assign a list of values to another list of values by their respective Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484262#M125709</link>
      <description>&lt;P&gt;The algorithm relies on the groups being the same in both sets.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 05:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484262#M125709</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-08-06T05:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Equally assign a list of values to another list of values by their respective Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484264#M125711</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/141869"&gt;@t30&lt;/a&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can store the staff names along with group in a multidata hash table, then look it up by group for each record from HAVE. The search makes all staff names for this group available for selection. Then you just select one randomly.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                      
  input custid:$8. group:$1. ;                   
  cards ;                                        
ABC123    A                                      
DEF456    A                                      
GHI789    C                                      
JKL101    A                                      
MNO112    B                                      
F000131   B                                      
G000415   C                                      
run ;                                            
                                                 
data names ;                                     
  input name:$8. group:$1. ;                     
  cards ;                                        
JOHN      A                                      
PAUL      A                                      
SARTRE    A                                      
RICHARD   B                                      
OLSEN     B                                      
LYKKE     B                                      
CHUCK     C                                      
NORRIS    C                                      
run ;                                            
                                                 
data want (keep = custid group name) ;           
  if _n_ =1 then do ;                            
    if 0 then set names ;                        
    call streaminit (7) ;                        
    dcl hash s (dataset:"names", multidata:"y") ;
    s.defineKey ("group") ;                      
    s.defineData ("name") ;                      
    s.defineDone () ;                            
  end ;                                          
  set have ;                                     
  do range = 0 by 1 while (s.do_over() = 0) ;    
  end ;                                          
  r = rand ("integer", range) ;                  
  do range = 1 by 1 while (s.do_over() = 0) ;    
    if r = range then output ;                   
  end ;                                          
run ;                                            &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;FWIW&lt;/P&gt;&lt;P&gt;Paul D.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 05:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484264#M125711</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-08-06T05:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Equally assign a list of values to another list of values by their respective Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484266#M125712</link>
      <description>Yes correct, real life is a bit messy I guess &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Aug 2018 06:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484266#M125712</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T06:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Equally assign a list of values to another list of values by their respective Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484267#M125713</link>
      <description>Unknown method DO_OVER for DATASTEP.HASH&lt;BR /&gt;&lt;BR /&gt;any SAS specific version for this? I'm using SAS 9.3, mostly only SAS Base</description>
      <pubDate>Mon, 06 Aug 2018 06:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484267#M125713</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T06:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Equally assign a list of values to another list of values by their respective Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484269#M125714</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/141869"&gt;@t30&lt;/a&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The DO_OVER method was unveiled in 9.4. If you have 9.3, use the code below instead. It works in both 9.4 and 9.3. Also note the changes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- From rand("integer", range) to ceil(rand("uniform")*range) because the former isn't available in 9.3, either, so in 9.3 you have to do some extra arithmetic&lt;/P&gt;&lt;P&gt;-- From 0 to 1 in the FROM expression of the first DO loop because of the change from WHILE to UNTIL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep = custid group name) ;                               
  if _n_ = 1 then do ;                                                
    if 0 then set names ;                                            
    call streaminit (7) ;                                            
    dcl hash s (dataset:"names", multidata:"y") ;                    
    s.defineKey ("group") ;                                          
    s.defineData ("name") ;                                          
    s.defineDone () ;                                                
  end ;                                                              
  set have ;                                                         
  if s.find() = 0 then do range = &lt;FONT color="#800000"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/FONT&gt; by 1 &lt;FONT color="#800000"&gt;&lt;STRONG&gt;until&lt;/STRONG&gt;&lt;/FONT&gt; (s.find_next() &lt;FONT color="#800000"&gt;&lt;STRONG&gt;ne&lt;/STRONG&gt;&lt;/FONT&gt; 0) ;
  end ;                                                              
  r = rand ("integer", range) ;                                      
  if s.find() = 0 then do range = 1 by 1 &lt;FONT color="#800000"&gt;&lt;STRONG&gt;until&lt;/STRONG&gt;&lt;/FONT&gt; (s.find_next() &lt;FONT color="#800000"&gt;&lt;STRONG&gt;ne&lt;/STRONG&gt;&lt;/FONT&gt; 0) ;
    if r = range then output ;                                       
  end ;                                                              
run ;                                                                &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;With those changes, the output will be the same in 9.3 and 9.4 since it's not the algorithm itself that changes, just its version-specific implementation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 06:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484269#M125714</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-08-06T06:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Equally assign a list of values to another list of values by their respective Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484271#M125715</link>
      <description>Thanks Paul, by the way, what do you intend to do with the rand function there? Normally rand only take the distribution function and has only 1 parametre</description>
      <pubDate>Mon, 06 Aug 2018 06:54:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-assign-a-list-of-values-to-another-list-of-values-by/m-p/484271#M125715</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-06T06:54:38Z</dc:date>
    </item>
  </channel>
</rss>

