SAS OnlineTutorback||next

Try It! Using the Hrd.Survey data set, define and process a two-dimensional array.

Creating HTML output? Read this first.

  1. Copy the program below and paste it into the Program Editor window (or issue the command copy sashelp.oltutor..source).
     data hrd.summary(drop=i j total);
        set hrd.survey;
        array section(3) eating 
exercise stress;
array resp( ? do i=1 to ? Total=0; do j=1 to ? total+(resp(i,j)); end; section(i)=total/6; end; run;
Then complete the program by replacing the question marks (?). Begin by grouping the variables Item1 through Item18 into a two-dimensional array of 3 rows of 6 elements.
Table Representation of resp Array
Eating: Item1 Item2 Item3 Item4 Item5 Item6
Exercise: Item7 Item8 Item9 Item10 Item11 Item12
Stress: Item13 Item14 Item15 Item16 Item17 Item18

  1. Next, complete the DO loop. Make it perform its calculation on each group of survey questions.

  2. Submit the DATA step, correct any errors, and then print the new data set.

    Return here and select Next.

Solution
back||next


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

Terms of Use & Legal Information | Privacy Statement