array x{1:5,1:3} score1-score15;
data zz;
input d1-d7;
array day(*) d1-d7;
do i=1 to dim(day);
day(i)=day(i)+10;
end;
drop i;
cards;
99 11 22 222 22 3 44
1 2 3 4 5 6 7
;
run;
PROC PRINT;RUN;
data a;
input x1-x5;
cards;
1 2 3 4 5
2 3 4 5 6
4 5 6 7 8
;
run;
data b;
set a;
array test(5) x1-x5;
prod=0;
do i=1 to dim(test)-1;
if i=1 then prod=test(i);
prod=prod*test(i+1);
end;
proc print;
run;
data a;
input var1 var2 var3;
cards;
10 20 30
100 . 300
. 40 400
;
run;
data b(drop=i);
set a;
array array1(3) _TEMPORARY_ (.1 .2 .3) ;
array array2(3) var1 var2 var3;/*把a数据集中的多个变量用数组来表示*/
do i=1 to 3;
if array2(i)=. then array2(i)=array1(i);
end;
proc print;
run;
如:array x x1-x5
data test;
input sco1-sco5;
array s sco1-sco5;
do _i_ =1 to 5;
s=s*100;
end;
cards;
0.95 0.88 0.57 0.90 0.65
1 2 3 4 5
;
run;
PROC PRINT;RUN;
其中i是这个数组的下标变量,k是数组元素的个数。
data test;
input sc01-sc05;
array s sc01-sc05;
do over s;
s=s*100;
end;
cards;
0.95 0.88 0.57 0.90 0.65
1 2 3 4 5
;
PROC PRINT;
RUN;
data infex;
informat default=3.1 default=$char4. x1 2.2;
/*数值的输入格式忽略w.d格式中w的值*/
input x1-x5 name $;
file print;
put x1-x5 name;
cards;
1111 22 33 4444 100 Johnny
;
run;
data;
informat a dollar9.;/*必须指定,否则不能识别数据*/
format a comma9.;
input a @@;
cards;
$1900000
;
run;
proc print;
run;
data ff;
format header $7. name $8.;
input header= name=;
cards;
header=zxs zjy name=zhou aaa
header=123 name=aaa
;
run;
proc print;
run;
drop variable-list
keep variable-list
data retire;
input amount @@;
retain year 1994 total 0;
year=year+1;
total=total+amount;/*total=sum(total,amount)*/
/*可用下列语句代替
retain year 1994;
year+1;
total+amount;*/
cards;
500 1000 1500 2200 2700
;
run;
proc print;
run;
data group;
input x;
retain;
if x=1 then sex='M';
if x=2 then sex='F';
cards;
1
2
3
2
;
run;
proc print;
run;
data a;
input x @@;
attrib x label='中国载人飞船'
length=8
informat=comma8.
format=dollar12.;
cards;
12,345,678
;
run;
proc print;
run;
data _null_;
window start
#5 @26 'welcome to the sas system' color=yellow
#7 @19 'this program creates two sas data sets'
#8 @26 'and uses three procedures'
#12 @27 'press enter to continue';
display start;
stop;
run;