task > Create two arrays that can be used to access the number of students in grades 7 through 12 from each of your two input data sets. Create a third array that will create and access new variables named Grade7 through Grade12. i have two data sets ok_mid and ok_high, now i want to make two arrays to access Grade7 - Grade12 from both data sets to add them. So far i have only seen one array - one data sets in a scope examples. how can i achieve above task thanks. proc sort data=data.ok_mid out=mid_sorted(rename=(Grade7-Grade12=MS_Grade7-MS_Grade12)); by MapCity School; run;
proc sort data=data.ok_high out=high_sorted(rename=(Grade7-Grade12=HS_Grade7-HS_Grade12)); by MapCity School; run;
data Both Midonly (keep=School MapCity MailCity County) HSonly (keep=School MapCity MailCity County);
merge mid_sorted (in=A)
high_sorted (in=B);
by MapCity School;
if A=1 and B=1 then output Both;
/*(b) create a temporary data set of high schools with no matching record in ok_mid*/
else if A=0 and B=1 then output HSonly;
/*(c) create a temporary data set of middle schools with no matching record in ok_high*/
else if A=1 and B=0 then output Midonly;
run;
data;
set high_sorted;
array hs_array {6} HS_Grade7-HS_grade12;
set mid_sorted;
array ms_array {6} MS_Grade7-MS_Grade12;
array new_array {6} Grade7-Grade12;
do i =1 to 6;
new_array[i] = hs_array[i] + ms_array[i];
end;
run;
... View more