由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS code 求助
相关主题
sas code求助问个菜鸟问题: why is X 5 and index is 7?
请帮忙看3道SAS题。关于SQL的问题
问个比较具体的算法问题nodupkey 删除的observations怎么查看?
问个sas问题(包子)问SAS adv 真题里的一题
sas question ( you bao zi )请问Adv 63题 的第23题
问个问题sas proc sortADV 63题中的45题
How to Macro it in SAS?help!! help!! SAS help!! Urgent!!
sas adv 63题 52SAS ADV 63题中第45题
相关话题的讨论汇总
话题: child话题: index话题: repre话题: data话题: run
进入Statistics版参与讨论
1 (共1页)
l*******s
发帖数: 437
1
我感觉这个问题不难,却不知道怎么做。
问题:有500个孩子,每个孩子可能有1,2或多于2个代理人,我要给孩子编号,从001编
到500,代理人有相应的编号,00101,00102,......50001,50002.
谢谢!
h********o
发帖数: 103
2
Try this:
=================================
DATA TEST;
INPUT CHILD $ REPRE $ @@;
CARDS;
A AAA A CCC B BBB
B CCC B DDD C AAA
C DDD C EEE C FFF
;
PROC SORT DATA = TEST OUT = CHILD (KEEP = CHILD) NODUPKEY;
BY CHILD;
RUN;
PROC SORT DATA = TEST OUT = REPRE (KEEP = REPRE) NODUPKEY;
BY REPRE;
RUN;
DATA CHILD (DROP = INDEX);
SET CHILD;
INDEX + 1;
CHILD_INDEX = PUT(INDEX, Z3.);
RUN;
DATA REPRE (DROP = INDEX);
SET REPRE;
INDEX + 1;
REPRE_INDEX = PUT(INDEX, Z5.);
RUN;
PROC SQL;
CREATE TABLE FINAL AS
SELECT A.CHILD, A.REPRE, CHILD_INDEX, REPRE_INDEX
FROM TEST AS A LEFT JOIN CHILD AS B ON A.CHILD = B.CHILD
LEFT JOIN REPRE AS C ON A.REPRE = C.REPRE
ORDER BY A.CHILD, A.REPRE;
QUIT;
======================================================
CHILD_ REPRE_
CHILD REPRE INDEX INDEX
A AAA 001 00001
A CCC 001 00003
B BBB 002 00002
B CCC 002 00003
B DDD 002 00004
C AAA 003 00001
C DDD 003 00004
C EEE 003 00005
C FFF 003 00006
a****g
发帖数: 8131
3
child guardian
1 1
1 2
2 1
...
500
then convert them to character variable
do a series of string manipulation to achieve your goal

【在 l*******s 的大作中提到】
: 我感觉这个问题不难,却不知道怎么做。
: 问题:有500个孩子,每个孩子可能有1,2或多于2个代理人,我要给孩子编号,从001编
: 到500,代理人有相应的编号,00101,00102,......50001,50002.
: 谢谢!

l*******s
发帖数: 437
4
thank you very much!!!
lemonades,您好:
您转给 honglajiao,现金(伪币):20,收取手续费:0.2
同时附加了如下留言给 honglajiao.
thanks

【在 h********o 的大作中提到】
: Try this:
: =================================
: DATA TEST;
: INPUT CHILD $ REPRE $ @@;
: CARDS;
: A AAA A CCC B BBB
: B CCC B DDD C AAA
: C DDD C EEE C FFF
: ;
: PROC SORT DATA = TEST OUT = CHILD (KEEP = CHILD) NODUPKEY;

j******o
发帖数: 127
5
孩子的代理有重复,你怎么编号?假如没有重复,可以试试下面:
data have;
input Child $ Guardian $;
datalines;
John David
John Mary
Ling Wang
Ling Peng
Ling Kevin
Lew Mike
;;
run;
proc sort data=have;
by child;
run;
data obtain(drop=G_number);
set have;
by child;
retain child_id;
if first.child then do;
child_id+1;
G_number=0;
end;
G_number +1;
Guardian_id=child_id*100+G_number;
format child_id z3. Guardian_id z5.;
run;
1 (共1页)
进入Statistics版参与讨论
相关主题
SAS ADV 63题中第45题sas question ( you bao zi )
请问两道sas adv的题..问个问题sas proc sort
SAS daily tips - PROC FREQHow to Macro it in SAS?
SAS daily tips - PROC GPLOTsas adv 63题 52
sas code求助问个菜鸟问题: why is X 5 and index is 7?
请帮忙看3道SAS题。关于SQL的问题
问个比较具体的算法问题nodupkey 删除的observations怎么查看?
问个sas问题(包子)问SAS adv 真题里的一题
相关话题的讨论汇总
话题: child话题: index话题: repre话题: data话题: run