Create a Data Set Using One Data Step Whenever Possible
Are two data steps necessary in the following code?
Data Scores; Input score1-score10; Datalines; 98 89 78 92 88 82 79 89 98 77 92 88 82 79 89 98 77 98 89 78 89 78 92 88 98 82 79 89 98 77 98 89 78 79 89 98 77 92 88 82 ; Data Grades; Set Scores; Grade = Mean(of Score1-Score10); run; Proc Means data=Grades; Var Grade; run;
Here is a more efficient way:
Data Grades; Input score1-score10; Grade = Mean(of Score1-Score10); Datalines; 98 89 78 92 88 82 79 89 98 77 92 88 82 79 89 98 77 98 89 78 89 78 92 88 98 82 79 89 98 77 98 89 78 79 89 98 77 92 88 82 ; Proc Means data=Grades; Var Grade; run;