BookmarkSubscribeRSS Feed
SASUserABC
Calcite | Level 5

Hoping you guys can help get me started.  I have a list of 500 students and 20 teachers and trying to allocate students to teachers based on a number of parameters such as maximum class size of 30, subject preference of student to subject specialisation of teacher, must not have had teacher in previous academic year etc. etc.

Would anyone be able to advise how I would get started on a simple allocation say on parameter of maximum class size so all classes have equal number of students.  I can then take this to optimise further by building in further parameters.

Struggling at this stage to get started with a basic approach, have tired arrays but no joy.

Many thanks

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well assigning them based on sequence is very simple:

data students;

  name="abc"; output;

  name="def"; output;

  name="egh"; output;

  name="wer"; output;

  name="lhj"; output;

run;

data teachers;

  teacher="xyz"; teach=1; output;

  teacher="iop"; teach=2; output;

run;

data temp; 

  set students;

  if _n_<=3 then teach=1;

  else teach=2;

run;

proc sql;

  create table WANT as

  select  A.TEACHER,

          B.NAME

  from    TEACHERS A

  left join TEMP B

  on      A.TEACH=B.TEACH;

quit;

Just assign them an id, each teacher has a unique id, each student is grouped based on _n_.  However I feel your other rules are going to be more complicated, i.e. if 90% of students want subject A, then how to arrive at which % of them go into one or the other.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1194 views
  • 3 likes
  • 2 in conversation