由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - A SAS Data Question
相关主题
问SAS code怎么写请教data mining 的问题,在线等,谢谢!
请教一个问题,谢谢。[请教]Q20in sas advance new (dec)
SAS code求教今天刚去考了SAS ADV
求助:一个SAS的小问题ADV 12月真题一问
请教一个SAS数据input的问题sas advance 12月真题Q20请教
SAS code questionsas adv 63题 第11
SAS input format questionsas adv 63题 11 (重发)
发包子请教一个SAS问题:=()One question about data step in sas
相关话题的讨论汇总
话题: score话题: 12话题: data话题: 15话题: sas
进入Statistics版参与讨论
1 (共1页)
e***7
发帖数: 862
1
My data looks like below:
id id_num score
1 1 12
1 2 14
1 3 12
2 1 15
2 2 15
3 1 11
3 2 12
I want to create an indicator say within each id, their score are different
(as long as one is different from another)
So it will look like:
id id_num score ind
1 1 12 1
1 2 14 1
1 3 12 1
2 1 15 0
2 2 15 0
3 1 11 1
3 2 12 1
Sorry cant type Chinese, Any inputs will be appreciated !
w*******9
发帖数: 1433
2
可以先选出符合条件的id, 在left join回去。
proc sql;
create table indicator as
select id, 1 as ind from RawData
group by id
having max(score) = min(score);
quit;
e***7
发帖数: 862
3
this works for numerical var (score), if my variable is a char variable, say
A, B, C how can I do it? Thanks!

【在 w*******9 的大作中提到】
: 可以先选出符合条件的id, 在left join回去。
: proc sql;
: create table indicator as
: select id, 1 as ind from RawData
: group by id
: having max(score) = min(score);
: quit;

w*******9
发帖数: 1433
4
I guess it still works. Letters have magnitudes in SAS.

say

【在 e***7 的大作中提到】
: this works for numerical var (score), if my variable is a char variable, say
: A, B, C how can I do it? Thanks!

e***7
发帖数: 862
5
if my var Field is something like ABS, HHJ, just curious how to select out
the flag ones

【在 w*******9 的大作中提到】
: I guess it still works. Letters have magnitudes in SAS.
:
: say

w*******9
发帖数: 1433
6
It does not matter. You do not need its exact numeric value. If you're
worried about this, you can count the unique number of records within each
id, then flag those having 1 distinct value.
proc sql;
select id, count(distinct(score)) as count from RawData
group by id;
quit;

【在 e***7 的大作中提到】
: if my var Field is something like ABS, HHJ, just curious how to select out
: the flag ones

l****u
发帖数: 529
7
proc sql;
create table two as
select *, min(score)^=max(score) as ind1, min(band)^=max(band) as ind2
from yourdata
group by id;
quit;
1 (共1页)
进入Statistics版参与讨论
相关主题
One question about data step in sas请教一个SAS数据input的问题
2013 January 刚考过SAS AdvSAS code question
讨论3道SAS ADV题目SAS input format question
SAS ADV 63题第11题求助发包子请教一个SAS问题:=()
问SAS code怎么写请教data mining 的问题,在线等,谢谢!
请教一个问题,谢谢。[请教]Q20in sas advance new (dec)
SAS code求教今天刚去考了SAS ADV
求助:一个SAS的小问题ADV 12月真题一问
相关话题的讨论汇总
话题: score话题: 12话题: data话题: 15话题: sas