SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Processing Variables with Arrays
Creating Multidimensional Arrays


Question: Write an ARRAY statement to group the variables Answer1 through Answer40 into a two-dimensional array that can be processed by the DO loop in this DATA step. Answer variables supply points to Quiz variables as follows:
     Answer1 -Answer10 -> Quiz1
     Answer11-Answer20 -> Quiz2
     Answer21-Answer30 -> Quiz3
     Answer31-Answer40 -> Quiz4
data master.scores;
   set master.quizzes;
   array score(4);
   
   do quiz=1 to 4;
      do points=1 to 10;
         score(quiz)+ans(quiz,points);
      end;
   end;
run;

           

  back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement