BookmarkSubscribeRSS Feed
Obsidian | Level 7

There are n number  of customers belongs to one branches and there multiple managers(say 3 managers in this case) in the same branch.

some customers are reserved to manager1, need to assign rest of the customers managers such that all the managers are assigned to equal number of customers.


Customer_NBR   Branch   Assign_ID

1                          abc         Manger1

2                          abc         Manager2

3                         abc          Manager2

4                         abc           --

5                         abc           --




100                    abc          --


After assigning mangers  to each customer, I would need each manager to have equal number of customers assigined


Manger1   34 Customers

Manager 2 33 Customers

Manager3   33 Customers




Jade | Level 19

Please post the data you have in usable form: a data step using datalines.


Without "some customers are reserved to managerX", proc rank could do the job, but i think some additional steps are required to fulfil the requirement.

Obsidian | Level 7

attached the data,


In sheet1 Customer_id is assigned to ID1, if that ID matches to manager in Sheet2 for that branch then Cu will get same manager. if not assign to other manager in the same branch. But Finally each manager should get equal number of Customers  assigned to them.


In this case, 

for abc branch,  below number customers assigned to each manager.

manager1-- 32

manager2-- 32

manager3-- 31


Thank you 



Opal | Level 21

So you have 3 tables to start with? Something like: customer_branch, branch_manager, manager_customer?

Or do you already have a single table to start with? If so where would we get the full list of all managers belonging to a branch (even the ones without pre-assigned customers)?

Posting sample data in form of a data step(s) is what helps us to spend the time answering your question instead of spending the time preparing sample data.


Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1 like
  • 4 in conversation