m***c 发帖数: 118 | 1 proc sql;
create table final(drop=n score2) as
select *,ifn(n=1and score2=min(score2),.,score2) as score3
from (select *,ifn(score<10,.,score) as score2,sum(score<10) as n from
one group by name)
group by name
order by name;
quit; |
|
e***e 发帖数: 236 | 2 The data is listed by country and rater names but I need to replace the
rater names by rater1, rater2, ... and by country.The problem is that each
country has different number of raters. Minimum 2 raters and maximum 10
raters. So the original data looks like this:
Country NLE name Score1 Score2 Score3
Argentina Serfaty, Edith 105 82
Argentina Kuper, Enrique 109 91
Argentina Mosca, Daniel 106 99
Brazil Nardi, Antonio ... 阅读全帖 |
|
a*********0 发帖数: 41 | 3 select mdate, team1, sum(score1), team2, sum(score2) from (SELECT mdate,
team1,
CASE WHEN teamid=team1 THEN 1 ELSE 0 END score1,
team2,
CASE WHEN teamid = team2 THEN 1 ELSE 0 END score2
FROM game left outer JOIN goal ON matchid = id) tmp
group by tmp.mdate, tmp.team1,tmp.team2
order by tmp.mdate, tmp.team1,tmp.team2
我在外面多加了个select 在里面求sum。 得分为0的没有漏洞而且答案看起来没什么问
题,只是没有得到笑脸 |
|
m******u 发帖数: 12400 | 4 我把你的表名换成了tblscores,不然容易与score 列明搞混。这个query运行成功。
select score1, score2, score3, score4, score5 from
(select score, 'score'+ cast(id as varchar(10)) as scoreSequence from
tblscores) as s
pivot
(sum(score)
for scoreSequence in (score1, score2, score3, score4, score5)) as p |
|
C*********y 发帖数: 1424 | 5 原数据是
5 90 80 70 77 88 23
2 100 99 25
3 87 85 88 35
第一组数是考试的次数,其他的是考试分数,最后一个数是年龄
想出的效果是这样的
Obs SCORE1 SCORE2 SCORE3 SCORE4 SCORE5 NUMBER SUBJ AGE
1 90 80 70 77 88 5 1 23
2 100 99 . . . 2 2 25
3 87 85 88 . . 3 3 35
必须用array做
应该如何写这个code呢
我写的
Data scoreproblem;
array array_score[5] score1-score5;
if array_score[i]<60 then array_score[i]=" "@;
input N score1 score2 score3 score4 score5 age;
datalines;
5 |
|
o******6 发帖数: 538 | 6 ☆─────────────────────────────────────☆
eucp (yuk) 于 (Wed Sep 16 01:38:22 2009, 美东) 提到:
data是score data,每个score是由5 items的分数加起来的。我用log2(score+1/9)之类
的转换,怎么也弄不到正态。这样的数据加一个constant的原则是什么,怎么加?
谢谢!
score1 freq
0 239
1 146
2 107
3 74
4 35
5 32
6 15
7 7
8 3
9 1
score2 freq
0 148
1 157
2 123
3 92
4 50
5 50
6 20
7 8
8 11
score2 freq
0 256
1 190
2 114
3 63
4 23
5 10
6 2
7 1
☆─────────────────────────────────────☆
DaS |
|
w******l 发帖数: 34 | 7 大侠能再具体讲一下log odds的可加性指什么吗
我知道logistics reg本身设计成indep是log odds就是为了能fit出来可加的
Linear sum of indep variables, 但是如果是不同的打分加在一起,还有道理吗,比如
score1 = log (p1/1-p1),
score2 = log(p2/1-p2),
那么score1 + score2 好像不好解释的通啊, 尤其是p1,p2不是independent的两件事情
的话 (虽然比直接p1 + p2多些道理)。
一个引申的问题就是, scorecards model是要把prob 转变成score的,一直不理解转
化的公式为什么要那么定义 :-) |
|
a****k 发帖数: 117 | 8 【 以下文字转载自 DataSciences 讨论区 】
发信人: andykk (andykk), 信区: DataSciences
标 题: 求教sqlzoo euro 2012 第十三题
发信站: BBS 未名空间站 (Sun Nov 23 20:53:17 2014, 美东)
题目在这:
http://www.sqlzoo.net/wiki/The_JOIN_operation
第十三题:
我的solution:
SELECT a.mdate, a.team1, SUM(CASE WHEN a.team1=b.teamid THEN 1 ELSE 0 END)
AS score1, a.team2, SUM(CASE WHEN a.team2=b.teamid THEN 1 ELSE 0 END) AS
score2 FROM game a LEFT JOIN goal b ON a.id = b.matchid GROUP BY b.matchid
ORDER BY a.mdate, a.id, a.team1, a.team2
这道题关键是不要漏掉0:0的比赛。我这个解法... 阅读全帖 |
|
a****k 发帖数: 117 | 9 多谢!你用的是sqlserver把?我用的是mysql, 加了coalesce,跟sqlserver里的ISNULL
功能一样。还是不对啊!
SELECT a.mdate, a.team1, COALESCE(SUM(CASE WHEN a.team1=b.teamid THEN 1 ELSE
0 END),0)
AS score1, a.team2, COALESCE(SUM(CASE WHEN a.team2=b.teamid THEN 1 ELSE 0
END), 0) AS
score2 FROM game a LEFT JOIN goal b ON a.id = b.matchid GROUP BY b.matchid
ORDER BY a.mdate, a.id, a.team1, a.team2 |
|
O*********e 发帖数: 90 | 10 是不是这样?
select mdate,
team1,
(select count(gtime)from goal where teamid = team1 and matchid = id) as
score1,
team2,
(select count(gtime)from goal where teamid = team2 and matchid = id) as
score2
FROM game
order by mdate |
|
s********e 发帖数: 893 | 11 比如table里数据是这样的:
ID Score
121 10
122 8
123 7
124 8
125 10
现在在report里想以这种方式显示,就是把5行换成5列。
Score1 Score2 Score3 Score4 Score5
10 8 7 8 10
请问各位这个怎么做?多谢了! |
|
m******u 发帖数: 12400 | 12 其实,列行转换不是像你举例中这种情形。比如,一个运动员(有个ID)参加一个比赛
,有多个成绩,这时table是这样的:
ID score
1 9.5
1 9.8
1 9.4
2 9.2
2 9.5
2 9.8
3 9.9
3 9.7
3 9.8
像转换成
ID score1 score2 score3
1 9.5 9.8 9.4
2 9.2 9.5 9.8
3 9.9 9.7 9.8 |
|
s********e 发帖数: 893 | 13 多谢楼上几位回复。实际的情况的确是meiyoutu说的这个样子。我给的例子里没有给出
每个人的ID。实际上每个人都只有5个Score。但是某一个人的5个score的ID可能是不连
续的。比如121-125的这5个score是1个人的,另一个人的5个score的ID可能是130,
135, 142,144,145.
我最后的query是先用Row_number partition by PersonID, sort by ID 给每个人的5
个score按照ID排了个序,就成这样:
ID PersonID Score RN
121 33 10 1
122 33 8 2
123 33 7 3
124 33 8 4
125 33 10 5
130 78 9 1
135 78 8 2
142 78 9 3
144 78 10 4
145 78 8 5
然后... 阅读全帖 |
|
y****n 发帖数: 46 | 14 Data scoreproblem;
array score(5) score1 score2 score3 score4 score5;
input N @;
do i=1 to n;
input score(i) @;
end;
input age;
drop i;
datalines;
5 90 80 70 77 88 23
2 100 99 25
3 87 85 88 35
;
run; |
|
n**********r 发帖数: 104 | 15 data x;
input Country $1-10 NLEName $14-29 Score1 32-35 Score2 37-44 Score3 46-50;
cards;
Argentina Serfaty, Edith 105 82
Argentina Kuper, Enrique 109 91
Argentina Mosca, Daniel 106 99
Brazil Nardi, Antonio 95 69
Brazil Marques, Tiago 96 73
Bulgaria Panayotov, Plamen 103 88
Bulgaria Kodorova, Koralia 100 90
;
data x (drop=id NLEName);
set x;
id+1;
by country;
if first.country t... 阅读全帖 |
|
a****k 发帖数: 117 | 16 题目在这:
http://www.sqlzoo.net/wiki/The_JOIN_operation
第十三题:
我的solution:
SELECT a.mdate, a.team1, SUM(CASE WHEN a.team1=b.teamid THEN 1 ELSE 0 END)
AS score1, a.team2, SUM(CASE WHEN a.team2=b.teamid THEN 1 ELSE 0 END) AS
score2 FROM game a LEFT JOIN goal b ON a.id = b.matchid GROUP BY b.matchid
ORDER BY a.mdate, a.id, a.team1, a.team2
这道题关键是不要漏掉0:0的比赛。我这个解法retrieve了24号的这场比赛,但为什么
27号的0:0没有retrieve出来? 有谁通过了sqlzoo的测试吗?多谢!
24 June 2012 ENG 0 ITA 0
27 June 2012 POR 0 ESP 0 |
|