全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1033 1
2013-12-24
悬赏 100 个论坛币 已解决
大家好,问题青年又来了。。。

遇到一个数值处理问题,想问问大家怎么处理比较好,谢谢。

规则:将数据集中的非整数进行向上或向下归类。不过困难的是,判断的时候,需要“向下看”,例如:

复制代码

数据中,例如在对2.5进行判断时候,看它后面的数值,如果2.5后面有(2+1),则2.5取2;
如果2.5后面没有(2+1),则2.5取为(2+1);
故,modify过后,第一个2.5变成2,第二个2.5变成3.

因为要by SUBJ,所以希望能包含一个分组过程。谢谢!!!

最佳答案

wwang111 查看完整内容

是这个意思吗? proc sort data=a out=b; by subj value; run; data _int; set b; by subj value; retain n; if index(put(value,best.),'.')>0 then n=int(value+1); if n=value then do;flag='int';output;end; run; proc sql; create table wanted as select subj,ifn(index(put(value,best.),'.')>0,int(value),value) as value from b where subj in (select distinct subj from _int) union ...
二维码

扫码加我 拉你入群

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

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

全部回复
2013-12-24 15:31:54
是这个意思吗?

proc sort data=a out=b;
by subj value;
run;
data _int;
set b;
by subj value;
retain n;
if index(put(value,best.),'.')>0 then n=int(value+1);
if n=value then do;flag='int';output;end;
run;

proc sql;
create table wanted as
select subj,ifn(index(put(value,best.),'.')>0,int(value),value) as value
from b
where subj in (select distinct subj from _int)
union all
select subj,ifn(index(put(value,best.),'.')>0,ceil(value),value) as value
from b
where subj not in (select distinct subj from _int)
order by subj,value;
quit;
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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