定义数组:ARRAY ARRAY_NAME(SUBSCRIPT) ($) VARIABLE-LIST ARRAY-VALUES
访问数组:PROC PRINT DATA =
ARRAY_NAME
;
OF运算符:
SUM = SUM(OF A(*));
MIN = MIN(OF A(*));
MEAN = MEAN(OF A(*));
IN运算符访问特定值:
IF 'XXX' IN COLOURS THEN available = 'Yes';ELSE available = 'No';
批量处理缺失值或特定值:
对数据集TMP的数值性字段为缺失值和<-999的批量赋值为-9999999;对字符字段缺失值统一赋值“-9999999”
DATA TMP1;
SET TMP;
ARRAY NUM_V _NUMERIC_;
DO OVER NUM_V;
IF MISSING(NUM_V) OR NUM_V<-999 THEN NUM_V=-9999999;
END;
ARRAY CHAR _CHAR_;
DO OVER CHAR;
IF MISSING(CHAR) THEN CHAR="-9999999";
END;
RUN;
DO TO语句批量赋值:
批量更改数据类型(把tmp中字符型字段批量变成数值型)
data _NULL_;
set tmp;
array tmp[*] _character_;
call symputx("nvar",dim(tmp));
run;
data tmp1;
set tmp end=eof;
array tmp[*] _character_;
length vars $32767.;
retain vars "";
array num[&nvar.];
do i=1 to dim(tmp);
num[i] = input (tmp[i],best12.);
if eof then vars=catx(" ",vars,cats(vname(num[i]),"=",vname(tmp[i])));
end;
if eof then call symputx("vars",vars);
drop _character_ i;
run;
%put &vars.;
data last;
set tmp1;
rename &vars.;
run;
(11条消息) SAS 数组_Silvanaxu的博客-CSDN博客_sas 数组
(11条消息) SAS|数组Array_小王很nice的博客-CSDN博客_sas array
(11条消息) sas 数组简介,sas数组批量处理缺失值和批量更改数据类型例子_暮雨听轩的博客-CSDN博客_sas数组
标签:tmp,vars,CHAR,数组,array,ARRAY From: https://www.cnblogs.com/Rachellaw/p/16849657.html