全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
7077 10
2011-01-09
求助SAS程序:
在分析的数据中要剔除这样一类变量,变量的所有取值一样或都是空值。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-1-9 22:53:23
复制代码


写的比较仓促,你先测试一下吧。 只要是观测值全部相同,就去掉。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-10 22:30:49
select count(distinct name) into:num
from b;
select distinct name into:num1-:num%left(&num)
from from b;
quit;
%macro a;
%do i=1 %to #
proc sort data=a;
by num&i;
run;
data c&i;
set a;
by num&i;
if first.num&i. then do;first_num&i=num&i.; flg&i=0;end;
if num&i ne first_num&i then flg&i+1;
if last.num&i. and flg&i=0 then list&i=num&i;
run;
%end;
%mend a;

%macro b;
data d;
set a(drop= %do j=1 %to # list&j %end;);
run;
%mend b;
%b
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-10 23:09:55
2# elek.me


运行了一下程序,还存在问题
提示错误:不允许混合隐式和显式数组下标
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-10 23:31:26
4# shirly_zhang 奇怪了。   数组定义时的
复制代码
都被自动抹去了,不知道怎么原因,我现在已经修改过了,你再试试吧。应该没有问题的
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-11 22:09:19
data have;
        input x0 $ x1-x4;
cards;

a 1 2 . 1

a 2 2 . 1

a 3 2 . 2

;
data _null_;
      if 0  then  set have;
        array cha[*] _character_;
        array num[*] _numeric_;
        call symputx ("nchar",dim(char));
        call symputx ("nnum",dim(num));
        stop;
run;

data _null_;
       set have end=last;
     array cha[*] _character_;
     array num[*] _numeric_;
array first_cha(&nchar) _temporary_;
array first_num(&nchar) _temporary_;
array flg_cha(&nchar) (&nchar*0);
array flg_num(&nnum) (&nnum*0);
length list $100;
if _n_=1 then do;
do i=1 to &nchar;
first_cha(i)=cha[i];
end;
do i=1 to &nnum;
first_num(i)=num[i];
end;
end;
do i=1 to &nchar;
if cha[i] ne first_cha(i) then flg_cha(i)+1;
end;
do i=1 to &nnum;
if num[i] ne first_num(i) then flg_num(i)+1;
end;
if last=1 then do;
do i=1 to &nchar;
if flg_cha(i)=0 then list=catx('',list,vname(cha[i]));
end;
do i=1 to &nnum;
if flg_num(i)=0 then list=catx('',list,vname(num[i]));
end;
call symput ('mlist',list);
end;
run;
data have;
set have (drop=&milst);
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群