Sie sind auf Seite 1von 7

SASTechies

info@sastechies.com
http://www.sastechies.com
data work.report;
input mon tue wed thr fri sat sun;
 A SAS array is a temporary put _all_;
grouping of SAS variables under a mon=5*(mon-32)/9;
single name. An array exists only tue=5*(tue-32)/9;
for the duration of the DATA step. wed=5*(wed-32)/9;
thr=5*(thr-32)/9;
fri=5*(fri-32)/9;
sat=5*(sat-32)/9;
sun=5*(sun-32)/9;
put _all_;
cards;
100 103 100 107 90 65 56
ARRAY array-name{dimension} elements; 70 30 32 40 50 80 0
;
where run;
array-name specifies the name of the array
dimension describes the number and arrangement
data work.report;
of array elements set master.temps;
elements lists the variables to include in the array. array wkday(7) mon tue wed thr fri sat sun;
do i=1 to 7;
wkday(i)=5*(wkday(i)-32)/9;
array sales {4}; end;
array sales {4} qtr1 qtr2 qtr3 qtr4; run;
array sales {*} qtr1 qtr2 qtr3 qtr4;
array sales{4} qtr1- qtr4;
array goal{4} g1 g2 g3 g4 (9000 9300 9600
9900);

SAS Techies 2009 11/02/21 2


SAS Data Set Hrd.Fitclass

Name Weight1 Weight2 Weight3 Weight4 Weight5 Weight6


Alicia 69.6 68.9 68.8 52.6 52.6 51.7
Brenda 68.6 67.6 67.0 67.6 66.6 66.0

SAS Techies 2009 11/02/21 3


data score2(drop=i);  create temporary array
array test{3} _temporary_ (90 80 70); elements for DATA step
array score{3} s1-s3; processing without creating
input id score{*}; new variables by specifying
do i=1 to 3; _TEMPORARY_
if score{i}>=test{i} then
do;
 Temporary array elements
NewScore=score{i};
do not appear in the
output;
resulting data set.
end;
 Temporary array elements
end; are useful when the array is
datalines; only needed to perform a
1234 99 60 82 calculation.
5678 80 85 75  You can improve
; performance time by using
run; temporary array elements.

SAS Techies 2009 11/02/21 4


array new{r,c} x1-x12;

 
array month{3,4} x1 x2 x3 x4 x5 x6 x7 x8
x9 x10 x11 x12;
                                         

      

array new{12} x1 x2 x3 x4 x5 x6 x7 x8 x9
x10 x11 x12;
Array Q{4};
do i=1 to 4;
Total=0;
do j=1 to 3;
Q(i)=total+mon(i,j);
end;
end;
SAS Techies 2009 11/02/21 5
data finance.quarters(drop=i j);
set finance.monthly;
array m(4,3) month1-month12;
array Qtr(4);
do i=1 to dim(Qtr);
do j=1 to 3;
qtr(i)+m(i,j);
end;
end;
run;

SAS Techies 2009 11/02/21 6


data temps;
array temprg{2,5} c1t1-c1t5 c2t1-c2t5;
input City1 $ c1t1-c1t5 /
City2 $ c2t1-c2t5;
do i=1 to 2;
do j=1 to 5;
temprg{i,j}=round(temprg{i,j});
end;
end;
datalines;
Fairfax 89.5 65.4 75.3 77.7 89.3
Frederic 73.7 87.3 89.9 98.2 35.6
Fairfax 75.8 82.1 98.2 93.5 67.7
Frederic 101.3 86.5 59.2 35.6 75.7
;
run;

SAS Techies 2009 11/02/21 7

Das könnte Ihnen auch gefallen