BookmarkSubscribeRSS Feed
Nasser_DRMCP
Lapis Lazuli | Level 10

Hello,

 

what I would like to obtain is to fill the column daytype_code in this "HAVE" table by respecting 4 rules.

rule 1°) each person should have one type1/week AND one type2/week AND one type3/week. But only one type(1 or 2 or 3) per date (and per person).

rule 2°) for each day, and each type (1,2,3), it should have at leat 2 persons

rule 3°) each person should have one type4 per month. it should be on saturday

rule 4°) each person should have one type5 in the week when he has a type4

 

important : I Don't ask you to develop the solution but just giving me please some advice on the logic, on the procedure, methode

thanks a lot in advance

regards

Nass

 

Data t_calendar ;
input day : DDMMYY10. ;
format day DDMMYY10. ;
datalines ;
01/07/2021
02/07/2021
03/07/2021
04/07/2021
05/07/2021
06/07/2021
07/07/2021
08/07/2021
09/07/2021
10/07/2021
11/07/2021
12/07/2021
13/07/2021
14/07/2021
15/07/2021
16/07/2021
17/07/2021
18/07/2021
19/07/2021
20/07/2021
21/07/2021
22/07/2021
23/07/2021
24/07/2021
25/07/2021
26/07/2021
27/07/2021
28/07/2021
29/07/2021
30/07/2021
31/07/2021
;
run ;


data t_team ;
input person $ ;
datalines ;
Benjamin
David
Elise
Emma
Jean
Marie
Nadia
Patrick
Paul
Peter
Robert
Simon
Vadim
Martin
run ;

data t_daytype ;
length daytype_code $ 5 daytype_description $ 20;
input daytype_code $ daytype_description $ ;
datalines ;
type0 permanence_no
type1 permanence_8h
type2 permanence_18h
type3 permanence_19h30
type4 permanence_saturday
type5 day_off
run ;


proc sql ;
create table have as
select person , day , "type0" as daytype_code
from t_team , t_calendar 
order by 1 , 2 ;
quit ;
5 REPLIES 5
Oligolas
Barite | Level 11

Hi,

 

this should help you for a start:

PROC SQL ;
   CREATE TABLE have AS
      SELECT month(day) as month, week(day, 'w') as week, day , put(weekday(day),dowName.) as weekday, person , daytype_code, daytype_description
      FROM t_team , t_calendar, t_daytype 
      ORDER BY month, week, day, person , daytype_code
   ;
QUIT ;
________________________

- Cheers -

FreelanceReinh
Jade | Level 19

Hello @Nasser_DRMCP,

 

So, basically there is a matrix whose rows correspond to calendar days and whose columns correspond to persons and you want to populate this matrix with "day type" codes. Your rules define a relatively small subset of the huge set of possible matrices. Therefore, I think your best bet will be to use methods available in SAS/OR if you (unlike me) have this module licensed. For example, the constraint programming capabilities of PROC OPTMODEL sound like being useful for your task. You will likely get more specific advice by posting your problem in the Mathematical Optimization, Discrete-Event Simulation, and OR subforum (after a search in the existing posts there). Good luck!

Nasser_DRMCP
Lapis Lazuli | Level 10
hello
thanks for your respons . this module seams interesting but unfortunately we do not have the licence.

N
Oligolas
Barite | Level 11

In my eyes it looks like a randomisation.

 

rule 1°) each person should have one type1/week AND one type2/week AND one type3/week. But only one type(1 or 2 or 3) per date (and per person).

A)Can you have a type3 today and a type1 tomorrow?

 

rule 2°) for each day, and each type (1,2,3), it should have at leat 2 persons

B)Are you trying to get the maximum or the minimum possible occupation of persons per day and week?

 

rule 3°) each person should have one type4 per month. it should be on saturday

C)with 14 subjects and 4 weeks a month you would get an occupation of up to 4 persons a saturday, if I balance the groups, is that what you intend to do?

 

rule 4°) each person should have one type5 in the week when he has a type4

D)Otherwise no day off!? how many type5 per month?

 

E)And what are the rules for type0? what does type0 mean? How many per week/month?

F)what's the difference between Type0 and Type5?

G)Is there the intention to maximize or minimize some Types per week? get the less or the maximum occupation?

 

________________________

- Cheers -

Nasser_DRMCP
Lapis Lazuli | Level 10

Thanks for your help Oligolas. my respons below

 

rule 1°) each person should have one type1/week AND one type2/week AND one type3/week. But only one type(1 or 2 or 3) per date (and per person).

A)Can you have a type3 today and a type1 tomorrow? yes.

 

rule 2°) for each day, and each type (1,2,3), it should have at leat 2 persons

B)Are you trying to get the maximum or the minimum possible occupation of persons per day and week? I try to get the minimum wich is 4

 

rule 3°) each person should have one type4 per month. it should be on saturday

C)with 14 subjects and 4 weeks a month you would get an occupation of up to 4 persons a saturday, if I balance the groups, is that what you intend to do? no matter the number of subject on saturday. I just want that each person work at least one saturday per month

 

rule 4°) each person should have one type5 in the week when he has a type4

D)Otherwise no day off!? how many type5 per month? firstly, we Don't want to deal with the holidays (except the day off when you work on saturday)

 

E)And what are the rules for type0? what does type0 mean? How many per week/month? type0 (default value) means no constraint, ordinary day. for exmple, monday=type / tuesday=type2 / wednesday=type3, then Thursday and friday are type0

F)what's the difference between Type0 and Type5? type5 is a day off (your are at home) but type0 you work without constraint. type0 = you start/finish as standard (from 9AM to 5PM). type1 = you start at 8:00 AM / type2 = you finish at 6:00 PM / type3 = you finish at 7:30 PM

G)Is there the intention to maximize or minimize some Types per week? get the less or the maximum occupation? if it is possible, the intention is to minimize type per Week. get the less occupation. but respect the minimun of 2 persons for each  type and each day

 

many Thanks

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 389 views
  • 3 likes
  • 3 in conversation