由买买提看人间百态

topics

全部话题 - 话题: ind1
(共0页)
t****n
发帖数: 10724
1
*******************************************************************
HR SQL难题的三种解法
*******************************************************************
摘要
本文综合描术了针对养老院人事难题的多种SQL解法。
鸣谢
Beijing
===========================================================
解法1 -- Partition 法
===========================================================
可以参考wyr解法,本解法用了lead/lag,以及ROWS UNBOUNDED PRECEDING A... 阅读全帖
B*****g
发帖数: 34098
2
原理一样,就是要达到排序后分组的目的
借用原题数据,第一步的目标加上ind1,指示此行是否是超过30天的行
User StartDate EndDate ind1
1 12/2/2011 1/16/2012 0
1 3/4/2012 3/24/2012 1
1 4/5/2012 4/26/2012 0
1 5/14/2012 6/7/2012 0
2 3/5/2012 7/30/2012 0
2 8/4/2012 9/15/2012 0
3 6/5/2012 8/20/2012 0
假设结果是t1,t1是这样得到的,请自行优化
select t11.*,
t11.startdate - (select MAX(t12.enddate) from t t21 where .. < ..) ind11
from t t11
ind11是相差的天数,自行转化成ind1 0(<=30),1(>30)
借用原题数据,第二步的目标加上ind2,指示分组
User StartDate EndDate ind1 ind2
1 12/2/2011 1/16/2012 0 0
1 3/4/2012 3/2... 阅读全帖
B*****g
发帖数: 34098
3
可以参考wyr解法,本解法用了lead/lag,以及ROWS UNBOUNDED PRECEDING AND
CURRENT ROW
原理一样,就是要达到排序后分组的目的
借用原题数据,第一步的目标加上ind1,指示此行是否是超过30天的行
User StartDate EndDate ind1
1 12/2/2011 1/16/2012 0
1 3/4/2012 3/24/2012 1
1 4/5/2012 4/26/2012 0
1 5/14/2012 6/7/2012 0
2 3/5/2012 7/30/2012 0
2 8/4/2012 9/15/2012 0
3 6/5/2012 8/20/2012 0
假设结果是t1,t1是这样得到的,请自行优化
select t11.*,
(t11.startdate - (LEAD/LAG)? (end_date,1) over (PARTITION BY ?? ORDER BY ??
)) t11.ind11
from t t11
ind11是相差的天数,自行转化成ind1 0(<=30),1(>30)
借用原题数据,第二步的目标加上... 阅读全帖
b*****u
发帖数: 1978
4
来自主题: Football版 - 奇怪的比赛
Scene A:进攻到底线需要1码,四次攻不过去。
Scene B:B 约等于 A。
Scene A details:
1st-1, IND1 5:47 L. Maroney rushed to the right for no gain
2nd-1, IND1 5:13 L. Maroney rushed to the right for no gain
3rd-1, IND1 4:36 K. Orton incomplete pass to the right
4th-1, IND1 4:26 L. Maroney rushed to the left for no gain
Scene B details:
2nd-1, IND7 0:24 K. Orton incomplete pass to the left
3rd-1, IND7 0:20 K. Orton incomplete pass to the left
4th-1, IND7 0:12 M. Prater kicked a 25-yard field g
g******9
发帖数: 70
5
ind1 = 1
ind2 = 1
while ind1 < length(A) and ind2 < length(B)
if (A==B)
blahblah
ind1++
ind2++
else if (A < B)
ind1++
else
ind2++
end
end
d*******2
发帖数: 340
6
矩阵大小为N*N,ind1是纵坐标,ind2是横坐标,对于ind1+ind2=N或者ind1=ind2上的元
素不变,其余元素变零,请问该怎么写?先谢了!
a***r
发帖数: 420
7
来自主题: Statistics版 - [SAS]问个简单的data manipulation
比如有一个dataset
group($) id($)
1 IND1
1 IND2
2 IND3
2 IND4
3 IND5
3 IND6
想把它变成:
group($) id_1($) id_2($)
1 IND1 IND2
2 IND3 IND4
3 IND5 IND6
应该怎么做?
sorry这个问题版上肯定有人问过,但是时间比较紧来不及考古了
非常感谢!!
l*****e
发帖数: 1275
8
哦我明白你的意思了,现在received那里还是0,上面2位包子,多谢。
SKUs
Units
Status
Shipped
Received
FBA (6/7/13 8:23 PM) - 2 FBA13WZV77 RIC2 Jun 12, 2013 1 4
0 DELIVERED
View & Track
FBA (6/7/13 8:23 PM) - 3 FBA13WZV7W IND1 Jun 12, 2013 1 5
0 DELIVERED
i***r
发帖数: 1035
9
有2列随机数字(不重复),很大比如2个G,排序之后,我想找出所有共同的数字,比
如A开头可能是:
1
2
3
7
10
74
100
349
。。。
B是:
2
3
6
78
89
90
120
。。。
他们相同的部分是
2
3
所以我需要2边同时往下读,然后不停地track谁大。实际上我的data里面,B总是比A增
加的快,所以我写了2个for loop,对每一个A,看B里面有没有相同的,找到了就记下
位置,作为下次loop的起点。
我不是科班出身,觉得自己的算法很烂(目前发现work不错,没有问题),相信有优化
算法,故请教大家
谢谢!
附上我的code结构,注意不要笑岔气了:
ind3=1;
for ind1=1:length(A)
for ind2=ind3:length(B)
if (A==B)
blahblah
end
ind3=ind2;
end
end
s**u
发帖数: 383
10
来自主题: Statistics版 - WINBUG initials
经高手指导,compile 没有问题了, 但是initial 又出问题了, 说是NIL
dereference (read), 查了manual, 说是 'NIL dereference (read)' can occur at
compilation in some circumstances when an inappropriate transformation is
made, for example an array into a scalar.用gen initial也出现同样的error.
请高人指导,谢谢。
model {
for (i in 1:k-1) {
for (j in i+1:k){
win1[i,j] ~ dbin(p[i,j], n)
logit(p[i,j]) <- d[i]-d[j]}
# p[i] <- phi(d[ind1[i]] - d[ind2[i]])
}
d[1:k] ~dmnorm(dmu[ ]... 阅读全帖
h********o
发帖数: 103
11
来自主题: Statistics版 - [SAS]问个简单的data manipulation
Try this:
============================
DATA TEST;
INPUT GROUP $ ID $;
CARDS;
1 IND1
1 IND2
2 IND3
2 IND4
3 IND5
3 IND6
;
PROC SORT DATA = ONE;
BY GROUP;
RUN;
DATA ONE(RENAME = (ID = ID1))
TWO(RENAME = (ID = ID2)) ;
SET TEST;
BY GROUP;
IF FIRST.GROUP THEN OUTPUT ONE;
IF LAST.GROUP THEN OUTPUT TWO;
RUN;
DATA FINAL;
MERGE ONE TWO;
BY GROUP;
RUN;
c*****1
发帖数: 131
12
来自主题: Statistics版 - 借人 气问 两个 问题:
I think oloolo give the best answer for Q2.
However, in actual business, this can happen from time to time. We can not consult back with business and data side always. There should be a way to handle this kind of situation.
Add my 2 cents:
Check the distribution of variable x in data1 and data2. If frequency of x in ('TX' and 'NV') are small, and there are other predictors in the model besides x, you can still fit the model if you create indicators like this (it will take 'TX' and 'NV' into acco... 阅读全帖
k*******a
发帖数: 772
13
来自主题: Statistics版 - 一个常见的问题
下面这个例子可能和你比较类似 (来源:http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/)
%macro mylogit1(all_deps);
%let k=1;
%let dep = %scan(&all_deps, &k);
%do %while("&dep" NE "");
title "dependent variable is &dep";
proc logistic data=xxx des;
model &dep = ind1 ind2;
run;
%let k = %eval(&k + 1);
%let dep = %scan(&all_deps, &k);
%end;
%mend;
*run the program for the first three v's;
%mylogit1(v1 v2 v3)
l****u
发帖数: 529
14
来自主题: Statistics版 - A SAS Data Question
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;
(共0页)