Quantcast
Viewing all articles
Browse latest Browse all 310

retain or multiple by variables?

Hi!

I have a situation where the data look like the following:

Code:

Student      Teacher    Grade
John              1              15
John              2              14
John              3              14
John              4              14
Sara              3              12
Sara              4              12
Matt              1              19
Jane              4              12
Jane              1              12

So here I have a dataset of Students who took a test with different teachers. My aim is to extract the highest grade achieved for each student, and the accompanying teacher. In the dataset, It's possible to have ties on the highest grades. In this case, I'd just like to make a new variable called 'flag' and give it a value of 'T'. For these students the Grade and the Teacher is irrelevant - I'm only interested in knowing that there was a tie, if the tie is the highest grade.

So for example, my output dataset (based on the above) would look like the following.


Code:

Student      Teacher    Grade    Flag
John              1              15      .
Sara              4              12      T
Matt              1              19      .
Jane              1              12      T

I've been playing around with retain statements and have looked into using multiple by variables (i.e, first.student, first.teacher) and I think retain is the way to go. I can't exactly shown what I've attempted as the code is located on the unix. Could anyone offer some tips for writing code to perform this task?

Viewing all articles
Browse latest Browse all 310

Trending Articles