昨天已经发过一个100论坛币悬赏贴,一位热心网友已经给我详细解答了那个macro代码的各个部分,我把他的答案设为最佳答案,也让大家参考学习一下。我还有几个问题求教各位。这是一个我组上在做的research,按照老板的要求和teammate的讨论,我需要往以下几个方向编代码,SAS新手在此再发两个悬赏帖竭诚向大家求教了。
Sample Data: StudentScore
| StudentID | Year | Score |
| A | 91 | 400 |
| A | 92 | 398 |
| A | 92 | 399 |
| B | 91 | 430 |
| B | 92 | 432 |
| B | 93 | 444 |
| B | 94 | 446 |
| C | 91 | 455 |
| C | 92 | 423 |
| C | 93 | 411 |
| C | 94 | 415 |
| C | 95 | 427 |
| C | 95 | 418 |
Q1. Create a variable called “inorde” which indicates whethera student’s score increased or decreased from the previous record in the data. Marka “0” for records where the student’s score was lower than the previous record.Conversely, mark a “1” for records where a student’s score was equal or higherthan the previous record. Mark a “0” for the first record of each student.
Q2. Write code to create a SAS dataset named“StudentScore2” by picking each student’s most recent score. If there aremultiple scores for the most recent year, then pick the highest one for thatyear.
Q3. Tag on the following variables to “StudentScore2” fromthe above question.
1.
HighScore: the highest score of each student. (Use“StudentScore” as the input)
2.
AvgScore: Average score for each student. (Use“StudentScore” as the input)