Hi all,
I'm having trouble generating variables based on a certain condition. Below is a simple example. I'm trying to generate a variable that will be filled with a school name (in this case, either Brown or Gordon) if that school has the lowest corresponding distance in the column. For example, If I were to create a new variable (say, SchoolMatch01) based on Distance01, it would fill out with "Brown." Another variable based on Distance02 would be filled with "Gordon." Is there any easy way to code for this? I've tried using macro commands but I can't figure out how to get some sort of minimization function in there. Please let me know if there is any difficulty understanding the question. It is somewhat hard to explain.
Thanks,
Thomas
I'm having trouble generating variables based on a certain condition. Below is a simple example. I'm trying to generate a variable that will be filled with a school name (in this case, either Brown or Gordon) if that school has the lowest corresponding distance in the column. For example, If I were to create a new variable (say, SchoolMatch01) based on Distance01, it would fill out with "Brown." Another variable based on Distance02 would be filled with "Gordon." Is there any easy way to code for this? I've tried using macro commands but I can't figure out how to get some sort of minimization function in there. Please let me know if there is any difficulty understanding the question. It is somewhat hard to explain.
Thanks,
Thomas
ID | School | Distance01 | Distance02 |
1 | Brown | 4 | 9 |
2 | Gordon | 7 | 2 |
3 | Reno | 9 | 4 |
Comment