由买买提看人间百态

topics

全部话题 - 话题: idnew
(共0页)
m**o
发帖数: 846
1
来自主题: Statistics版 - An interesting question from mysas.net/forum
缺了一次sorting,所以丟了一层关系,需要重新用原来的ID来sort,才能把原来的关
系带上。
%macro setID(idvar);
proc sort data=a2; by &idvar idnew;
稍微修改一下,保留原来的ID和新的ID;
data a2 /*(drop=idT)*/;
set a2;
by &idvar idnew;
retain idT;
if first.&idvar then idT =idnew;
/* else if idT^=idnew then idnew =idT; */
run;
》》》》》》》》》》》》》》然后加一段应该就可以了:
proc sort data=a2; by idnew idT;
data a2(drop=idT idnew rename=(idT2=idnew));
set a2;
by idnew idT;
retain idT2;
if first.idnew then idT2=idT;
run;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
m**o
发帖数: 846
2
来自主题: Statistics版 - An interesting question from mysas.net/forum
你这个loop会陷入死循环的,不能始终对&idvar排序,需要对idnew and idT交替排序,
i.e.
sort by &idvar idnew -> 生成 idT
sort by idnew idT -> 生成的新ID replace "idnew"
sort by idT idnew -> 生成的新ID replace "idT"
sort by idnew idT -> idnew
sort by idT idnew -> idT
.......
每排一次,可以展开一层后代,i.e. 如果最多有n层后代,那么至多需要排序n次。
这个做法的问题是,因为数据量很大(10GB),不能无限制的排序下去,所以最好加一
个中断条件就是,至多排序m次,i.e. 至多展开到第m代后代,以后的后代就不算成一
家了。无限展开下去也没有多少实际意义。
u******e
发帖数: 60
3
来自主题: Statistics版 - An interesting question from mysas.net/forum
Please try this one.
data a2;
set a1 ;
idnew =id4;
run;
%macro setID(idvar);
%let complete=no;
%let idnewFrom=;
%let idnewTo=;
%do %while (&complete=no);
proc sort data=a2; by &idvar idnew;
data a2(drop=idT change);
set a2 end=last;
by &idvar idnew;
retain idT change;
Preidnew =idnew;
if _N_=1 then change=0;
if first.&idvar and change=0 then idT =idnew;
else do;
if change=0 and idT ^= idnew then do;
call symput("idnewFrom", left(idnew));
u******e
发帖数: 60
4
来自主题: Statistics版 - An interesting question from mysas.net/forum
The idea is as below. The loop is controlled by macro variable COMPLETE. By
the end of loop 4 in the data as below, COMPLETE was set to yes, so it won't
end in dead circle.
I agree with your point that it is not efficient for large data.
loop 1 loop 2 loop 3 loop 4
id3 idnew id3 idnew id3 idnew id3 idnew
1 1 1 1 1 1 1 1
1 2 ->1 1 1 1 1 1 1
1 3 1 3->1 1 1 1 1
2 1 2 1 2 1 2 1
2
u******e
发帖数: 60
5
来自主题: Statistics版 - An interesting question from mysas.net/forum
I tried the example provided by "babyface". The idnew were set to 3 for all
five records in loop 3.
The change of idnew is controlled by the two macro variables "idnewFrom" and
"idnewTo". If you add PROC PRINT in the macro, you will see how each loop
works.
The statement 'Preidnew =idnew;" can be deleted. It was used when I tested
the macro.
u******e
发帖数: 60
6
来自主题: Statistics版 - An interesting question from mysas.net/forum
- loop 1 -

id1 id2 idnew
3 2 3
5 2 3
4 4 4
5 4 3
5 5 3
- loop 2 -

id1 id2 idnew
3 2 3
5 2 3
5 4 3
4 4 3
5 5 3
- loop 3 - COMPLETE was change from “no” to “yes” in this loop.
d*********o
发帖数: 6388
7
http://www.caacnews.com.cn/newsshow.aspx?idnews=191426
近年来成都航空业务量增长迅速,去年旅客吞吐量首次超过深圳机场,成为国内航空第四城。
成都机场国内通达率居全国第二 仅次于北京。
成都是中西部唯一的美国联合包裹、联邦快递、敦豪速递三大快递巨头同时通航的城市。
根据规划,到2015年,成都机场国际定期通航点将达到32个,支线机场覆盖率将达到30%以上,旅客吞吐量4500万人次,货邮吞吐量86万吨,均力争进入世界排名前30位;到2020年,旅客吞吐量7000万人次,货邮吞吐量140万吨,均力争进入世界排名前25位。
新航站楼将起降空客A380
昨日,记者从四川省机场集团了解到,2009年开建的双流机场新航站楼现已进入装修收尾、设备安装阶段,计划于6月底竣工,今年暑运(7月起)投入使用。届时,总面积达50万平方米的候机楼能满足年5000万旅客吞吐量。南航成都营业部有关负责人表示,新航站楼启用后,南航将在成都飞北京的航线上率先引入宽体型的空客A380机型。
从机场二跑道到新航站楼,再到机场站前设施建设,成都机场的变化日新月异,继续领跑中... 阅读全帖
d*********o
发帖数: 6388
8
http://www.caacnews.com.cn/newsshow.aspx?idnews=267845
目前,正值傣族一年一度最盛大的传统节日“泼水节”,人们把这一天视为最吉祥、最
美好的日子。为了迎接这富有云南本土特色的傣历新年,并更好的对外宣传云南少数民
族文化,打造瑞丽航空特色服务品牌,2015年4月13日至4月16日,瑞丽航空在多个航班
上同时开展了机上“泼水节”特色服务活动。
H*****r
发帖数: 106
u******e
发帖数: 60
10
来自主题: Statistics版 - An interesting question from mysas.net/forum
First check the frequency of id1, id2, id3, id4. The number of levels of the
new id has to be smaller than the one with smallest number of levels. In
the example data, it is id4. Use the following macro for all the other three
variables, from the one with less number of levels to the one with more
number of levels. In the exaple, the order of id1 and id2 does not matter
since they both have 4 levels.
The only issue is sorting may take time.
data a2;
set a1;
idnew =id4;
run;
%macro setID
b******e
发帖数: 539
11
来自主题: Statistics版 - An interesting question from mysas.net/forum
还是不对,试试这组简单的数据:
data a3;
input id1 id2;
datalines;
3 2
5 2
4 4
5 4
5 5
;
run;
data a2;
set a3;
idnew=id1;
run;
%setID(id2);
m**o
发帖数: 846
12
来自主题: Statistics版 - An interesting question from mysas.net/forum
You are right, the loop won't be dead, but it would not be able to catch all
descendants either.
To test this, you can just test your code on the simple example "babyface"
provided above.
BTW: in your example, in loop2, id3=3, idnew=3 can not turn to 1

By
't
u******e
发帖数: 60
13
来自主题: Statistics版 - An interesting question from mysas.net/forum
I found a bug and fixed it.
%macro setID(idA, idB);
%let complete=no;
%let idnewVal=;
%let Ahook=;
%let Bhook=;
data a1new;
idnew=.;
run;
** copy idA and idB to A and B;
data a1;
set a1;
A = &idA;
B = &idB;
run;
%let i=0;
%do %while (&complete=no);
%let i=%eval(&i +1);
%let A1Val=;
%let A2Val=;
%let A3Val=;
%let B1Val=;
%let B2Val=;
%let B3Val=;
data a1;
set a1 end=last;
retain A1-A3 Anum B1-B3 Bnum;
if _N_=1 then do;
** if no hook links the current and previous
(共0页)