<?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 proc surveyselect and grouping in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/690980#M210255</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using Sas Enterprice Guide 7.1 and I have a question about using proc survey and grouping.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 21 customer with different amount ,score and state.I want to assign customers to the sellers with the rates below.&lt;/P&gt;&lt;P&gt;%35 number and amount of customers will be in jane portfolio,% 50&amp;nbsp;and amount of customers will be in mark's portfolio and&amp;nbsp;%15 number and amount of customers will be in Sandy's portfolio . Also I want to treat the sellers equally so I also want that if jane taking %35 of customers , these customers must have approximately same score and state with Mark and Jane's customers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data like that ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data assignment;&lt;BR /&gt;input customer amount score $ state $ ;&lt;BR /&gt;cards;&lt;BR /&gt;1 1000 good paris&lt;BR /&gt;2 4000 good london&lt;BR /&gt;3 3000 good paris&lt;BR /&gt;4 1000 bad berlin&lt;BR /&gt;5 2000 middle paris&lt;BR /&gt;6 5000 good milan&lt;BR /&gt;7 7000 middle rome&lt;BR /&gt;8 4000 good london&lt;BR /&gt;9 2000 middle berlin&lt;BR /&gt;10 6000 bad madrid&lt;BR /&gt;11 2000 good paris&lt;BR /&gt;12 1000 good london&lt;BR /&gt;13 3000 good milan&lt;BR /&gt;14 5000 bad berlin&lt;BR /&gt;15 7000 middle paris&lt;BR /&gt;16 4000 good milan&lt;BR /&gt;17 8000 bad milan&lt;BR /&gt;18 3000 good berlin&lt;BR /&gt;19 2000 middle berlin&lt;BR /&gt;20 4000 bad madrid&lt;BR /&gt;21 4000 bad paris&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Data rate;&lt;BR /&gt;input seller $ rate ;&lt;BR /&gt;cards;&lt;BR /&gt;Jane 0.35&lt;BR /&gt;Mark 0.50&lt;BR /&gt;Sandy 0.15&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you ...&lt;/P&gt;</description>
    <pubDate>Mon, 12 Oct 2020 14:11:26 GMT</pubDate>
    <dc:creator>yukki</dc:creator>
    <dc:date>2020-10-12T14:11:26Z</dc:date>
    <item>
      <title>proc surveyselect and grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/690980#M210255</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using Sas Enterprice Guide 7.1 and I have a question about using proc survey and grouping.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 21 customer with different amount ,score and state.I want to assign customers to the sellers with the rates below.&lt;/P&gt;&lt;P&gt;%35 number and amount of customers will be in jane portfolio,% 50&amp;nbsp;and amount of customers will be in mark's portfolio and&amp;nbsp;%15 number and amount of customers will be in Sandy's portfolio . Also I want to treat the sellers equally so I also want that if jane taking %35 of customers , these customers must have approximately same score and state with Mark and Jane's customers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data like that ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data assignment;&lt;BR /&gt;input customer amount score $ state $ ;&lt;BR /&gt;cards;&lt;BR /&gt;1 1000 good paris&lt;BR /&gt;2 4000 good london&lt;BR /&gt;3 3000 good paris&lt;BR /&gt;4 1000 bad berlin&lt;BR /&gt;5 2000 middle paris&lt;BR /&gt;6 5000 good milan&lt;BR /&gt;7 7000 middle rome&lt;BR /&gt;8 4000 good london&lt;BR /&gt;9 2000 middle berlin&lt;BR /&gt;10 6000 bad madrid&lt;BR /&gt;11 2000 good paris&lt;BR /&gt;12 1000 good london&lt;BR /&gt;13 3000 good milan&lt;BR /&gt;14 5000 bad berlin&lt;BR /&gt;15 7000 middle paris&lt;BR /&gt;16 4000 good milan&lt;BR /&gt;17 8000 bad milan&lt;BR /&gt;18 3000 good berlin&lt;BR /&gt;19 2000 middle berlin&lt;BR /&gt;20 4000 bad madrid&lt;BR /&gt;21 4000 bad paris&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Data rate;&lt;BR /&gt;input seller $ rate ;&lt;BR /&gt;cards;&lt;BR /&gt;Jane 0.35&lt;BR /&gt;Mark 0.50&lt;BR /&gt;Sandy 0.15&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you ...&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 14:11:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/690980#M210255</guid>
      <dc:creator>yukki</dc:creator>
      <dc:date>2020-10-12T14:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: proc surveyselect and grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/691066#M210292</link>
      <description>&lt;P&gt;Proc survey can generate some random group assignments, lots of them, but it cannot optimize or balance the groups as you describe. So what you can try is to generate many random assignments, say 1000, and pick the best one, according to some measure of variation. Here is an example where I select the assignment with the lowest total relative variation (relative frequency variation for &lt;EM&gt;score&lt;/EM&gt; and &lt;EM&gt;state&lt;/EM&gt;, mean variation for &lt;EM&gt;amount&lt;/EM&gt;) :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data assignment;
input customer amount score $ state $ ;
cards;
1 1000 good paris
2 4000 good london
3 3000 good paris
4 1000 bad berlin
5 2000 middle paris
6 5000 good milan
7 7000 middle rome
8 4000 good london
9 2000 middle berlin
10 6000 bad madrid
11 2000 good paris
12 1000 good london
13 3000 good milan
14 5000 bad berlin
15 7000 middle paris
16 4000 good milan
17 8000 bad milan
18 3000 good berlin
19 2000 middle berlin
20 4000 bad madrid
21 4000 bad paris
;

/* Proportions of customers to be assigned to each seller.
   ASSUMED TO SUM TO ONE */
Data rate;
input seller $ rate ;
/* Add an ID value, because surveyselect will identify groups with numbers */
sellerID + 1;
cards;
Jane 0.35
Mark 0.50
Sandy 0.15
;

/* Calculate the customer group size for each seller */
proc sql;
select round(rate*(select count(customer) from assignment))
into : groupSizes separated by " "
from rate
order by sellerID;
quit;

/* Generate 1000 random assignments of customers to sellers */
proc surveyselect data=assignment groups=(&amp;amp;groupSizes) 
    out=groups reps=1000 seed=98685;
run;

/* get the relative frequency of score and group levels for each group within 
   each random assignment */
proc freq data=groups;
by replicate;
tables groupID*score / sparse 
    out=groupScoreFreqs(drop=count pct_col percent) outpct noprint;
tables groupID*state / sparse 
    out=groupStateFreqs(drop=count pct_col percent) outpct noprint;
run;

/* Calculate the mean amounts for each seller for each random assignment */
proc summary data=groups noprint nway;
by replicate;
class groupID;
var amount;
output out=groupAmountMeans(drop=_type_ _freq_) mean=meanAmount;
run;

proc sql;
/* Sum the inter seller coefficients of variation (CV) for all criteria: 
   score, state and amounts */
create table CVs as
select 
    replicate,
    sum(cv) as totalCV
from (
    (select replicate, score as criteria, CV(PCT_ROW) as cv 
     from groupScoreFreqs group by replicate, score)
    union all
    (select replicate, state as criteria, CV(PCT_ROW) as cv 
     from groupStateFreqs group by replicate, state)
    union all
    (select replicate, "Amount" as criteria, CV(meanAmount) as cv 
     from groupAmountMeans group by replicate)
)
group by replicate;

/* Find the replicate with the lowest total CV */
create table bestReplicate as
select
    replicate,
    totalCV
from CVs
having totalCV = min(totalCV);

/* Extract the best random assignment, corresponding to the 
   lowest total variation */
create table bestGroups as
select sellerID, customer, amount, score, state 
from groups left join rate on groupID=sellerID
where replicate in (select replicate from bestReplicate)
order by sellerID, customer;
select * from bestGroups;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 258px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50576i80FBE7CAF67631AB/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 19:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/691066#M210292</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-10-12T19:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc surveyselect and grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/691145#M210317</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thank you for the solution . Is it possible to write it in sql developer?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 06:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/691145#M210317</guid>
      <dc:creator>yukki</dc:creator>
      <dc:date>2020-10-13T06:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: proc surveyselect and grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/691471#M210469</link>
      <description>Hi,&lt;BR /&gt;Thank you for the solution . I have one more question.&lt;BR /&gt;I also want the group's total amount distirubition close to the rate (%35 %50 %15 ). Is it possible?</description>
      <pubDate>Wed, 14 Oct 2020 08:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/691471#M210469</guid>
      <dc:creator>yukki</dc:creator>
      <dc:date>2020-10-14T08:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc surveyselect and grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/691549#M210496</link>
      <description>&lt;P&gt;Well, that's why I tried balancing the mean amount in my code. It is mathematically equivalent to sharing the total amount according to the rates (frequencies).&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 14:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/691549#M210496</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-10-14T14:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: proc surveyselect and grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/691656#M210544</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;I have one more problem also.This is harder i think&lt;/P&gt;&lt;P&gt;I want to make groups with the group sizes given but want this sizes from the given states.(table 1)&lt;/P&gt;&lt;P&gt;for exampe : I want to assign Jane 2 customers from Berlin,3 customers from paris, 1 customer from madrid&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also want to get the relative frequency of score provence and group levels for each group within each random assignment&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote the begining code but last part doesnt give the result i want&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;table 1;&lt;BR /&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt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/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;Linda&lt;/TD&gt;&lt;TD&gt;0.6&lt;/TD&gt;&lt;TD&gt;madrid&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1.2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;Data assignment;&lt;BR /&gt;input customer amount score $ state $ provence $ ;&lt;BR /&gt;cards;&lt;BR /&gt;1 1000 good paris aaaa&lt;BR /&gt;2 3000 good paris aaaa&lt;BR /&gt;3 1000 bad berlin bbbb&lt;BR /&gt;4 2000 middle paris cccc&lt;BR /&gt;5 5000 good milan dddd&lt;BR /&gt;6 2000 middle berlin bbbb&lt;BR /&gt;7 2000 good paris cccc&lt;BR /&gt;8 3000 good milan eeee&lt;BR /&gt;9 5000 bad berlin bbbb&lt;BR /&gt;10 7000 middle paris aaaa&lt;BR /&gt;11 4000 good milan eeee&lt;BR /&gt;12 8000 bad milan eeee&lt;BR /&gt;13 3000 good berlin ffff&lt;BR /&gt;14 2000 middle berlin ffff&lt;BR /&gt;15 4000 bad paris cccc&lt;BR /&gt;16 2000 bad london pppp&lt;BR /&gt;17 6000 middle london pppp&lt;BR /&gt;18 4000 good madrid kkkk&lt;BR /&gt;19 7000 bad tokyo nnnn&lt;BR /&gt;20 9000 bad madrid mmmm&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table Names as select distinct state from assignment;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc print;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/* Proportions of customers to be assigned to each seller.&lt;BR /&gt;ASSUMED TO SUM TO ONE */&lt;BR /&gt;Data rate;&lt;BR /&gt;input seller $ rate state $ ;&lt;BR /&gt;/* Add an ID value, because surveyselect will identify groups with numbers */&lt;BR /&gt;sellerID + 1;&lt;BR /&gt;cards;&lt;BR /&gt;Jane 0.35 berlin&lt;BR /&gt;Mark 0.65 berlin&lt;BR /&gt;Jane 0.50 paris&lt;BR /&gt;Lucy 0.50 paris&lt;BR /&gt;Linda 0.15 milan&lt;BR /&gt;Mark 0.85 milan&lt;BR /&gt;Linda 1 london&lt;BR /&gt;Lucy 0.20 tokyo&lt;BR /&gt;Mark 0.80 tokyo&lt;BR /&gt;Lucy 0.20 budapest&lt;BR /&gt;Mark 0.80 budapest&lt;BR /&gt;Jane 0.40 madrid&lt;BR /&gt;Linda 0.60 madrid&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;create table table1 as&lt;BR /&gt;select * from&lt;BR /&gt;(select a.*,b.state_sum,a.rate*b.state_sum as rate_state,&lt;BR /&gt;case when (round(a.rate*b.state_sum)-a.rate*b.state_sum)=0.5 THEN FLOOR(a.rate*b.state_sum)&lt;BR /&gt;WHEN round(a.rate*b.state_sum)&amp;gt;0.50 AND round(a.rate*b.state_sum)&amp;lt;1 THEN 1&lt;BR /&gt;ELSE round(a.rate*b.state_sum) END AS rate_state_r&lt;BR /&gt;from rate a,&lt;BR /&gt;(select state,count(*) as state_sum from assignment group by state) b&lt;BR /&gt;where&lt;BR /&gt;a.state=b.state&lt;BR /&gt;)&lt;BR /&gt;where rate_state_r&amp;gt;0 order by sellerID&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Calculate the customer group size for each seller */&lt;BR /&gt;proc sql;&lt;BR /&gt;select table1.rate_state_r&lt;BR /&gt;into : groupSizes separated by " "&lt;BR /&gt;from table1&lt;BR /&gt;order by sellerID;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Generate 1000 random assignments of customers to sellers */&lt;BR /&gt;proc surveyselect data=assignment groups=(&amp;amp;groupSizes)&lt;BR /&gt;out=groups reps=100000 seed=98685&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=groups (obs = 20) ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 19:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-surveyselect-and-grouping/m-p/691656#M210544</guid>
      <dc:creator>yukki</dc:creator>
      <dc:date>2020-10-14T19:53:59Z</dc:date>
    </item>
  </channel>
</rss>

