AAA教育论坛

标题: SAS数组的使用 [打印本页]

作者: 谷小燕老师    时间: 2018-3-4 22:28
标题: SAS数组的使用
/*数组是一组以特殊顺序排列并由数组名标识的SAS变量
array 数组名{下标}<$><长度><数组元素><(初始值列表)>
*/
data;
        array array1{3} a b c;
run;
data test_array;
set grade1;
        array array1{2} math chinese;
        do i=1 to 2;
                array1(i)=array1(i)**2;
        end;
        drop i;
run;


/*与上一方法功能一样*/
data test_array;
set grade1;
math=math**2;
chinese=chinese**2;
run;
/*如果列名的前缀一样,可以省略着写*/
data test;
        array array1{3} rev_1-rev_3;
        do i=1 to 3;
                do j=1 to 3;
                array1(j)=j;
                end;
                output;
        end;
    drop i j;
run;






欢迎光临 AAA教育论坛 (https://bbs.aaa-cg.com.cn/) X3.2