All of the examples we've looked at so far have involved performing only one action for a given condition. There may be situations in which you want to perform more than one action.
Example 5.10 Section
Suppose our instructor wants to assign a grade of zero to any student who missed the fourth exam, as well as notify the student that she has done so. The following SAS program illustrates the use of the DO-END clause to accommodate the instructors wishes:
DATA grades; input name $ 1-15 e1 e2 e3 e4 p1 f1; if e4 = . then do; e4 = 0; notify = 'YES'; end; DATALINES; Alexander Smith 78 82 86 69 97 80 John Simon 88 72 86 . 100 85 Patricia Jones 98 92 92 99 99 93 Jack Benedict 54 63 71 49 82 69 Rene Porter 100 62 88 74 98 92 ; RUN; PROC PRINT data = grades; var name e1 e2 e3 e4 p1 f1 notify; RUN;
The DO statement tells SAS to treat all of the statements it encounters as one all-inclusive action until a matching END appears. If no matching END appears, SAS will hiccup. Launch and run the SAS program, and review the output of the PRINT procedure to convince yourself that the program accomplishes what we claim.