由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - NEED HELP: write do loop in SAS for a project
相关主题
mysql 问题问一个简单的SAS问题,多谢
a SAS problem怎么用SAS sort 50G的data
如何在用SAS给多个data step 和proc step 做循环语句呢?SAS 求助:如何根据变量值输出变量名
请问如何把一个数据里所有的变量名后面都加个v?thanks.请教这个怎么用SAS简单实现
请教:三道SAS BASE题排序的问题,请问高手用SAS怎么做?
问一个sas改大量的variable name的问题SAS里怎么根据VALUE来选择需要OUTPUT的COLUMNS
问个SAS问题问个SAS的问题
SAS Questionmy revised resume
相关话题的讨论汇总
话题: hcc1话题: hcc3话题: hcc2话题: hcci话题: table
进入Statistics版参与讨论
1 (共1页)
t*******s
发帖数: 289
1
table 1
ID HCC1 HCC2 HCC3
a 0 1 1
b 1 1 1
c 1 1 0
d 1 0 0
e 0 0 0
f 0 0 0
g 1 1 0
h 1 1 0
i 1 1 1
j 0 1 1
k 0 0 1
l 0 0 0
m 1 0 0
n 1 0 0
o 1 0 0
p 0 0 1
q 0 1 1
r 0 1 1
s 0 1 0
t 0 0 0
table 2
ID HCC1 HCC2 HCC3
a 1 0 1
b 1 0 1
c 1 0 1
d 0 0 1
e 0 0 0
f 0 0 0
g 0 0 1
h 0 0 1
i 0 0 0
j 0 1 0
k 1 0 0
l 1 0 0
m 1 1 0
n 0 1 1
o 0 1 1
p 0 1 0
q 1 1 0
r 1 1 0
s 1 1 1
t 1 0 0
output table
ID HCC
a HCC2
b HCC3
c HCC4
d HCC1
g HCC1
h HCC1
i HCC1
g HCC2
h HCC2
i HCC2
i HCC3
n HCC1
o HCC1
p HCC3
q HCC3
r HCC3
logic:
join table 1 and 2 on id and HCCi; selecl id and HCCi where HCCi in table 1
is 1 and HCCi in table 2 is 0
l****u
发帖数: 529
2
I did not check.
data t3;
merge t1 t2(rename=(hcc1=hcc4 hcc2=hcc5 hcc3=hcc6));
by id;
array new1 [3] hcc1 hcc2 hcc3;
array new2 [3] hcc4 hcc5 hcc6;
do i=1 to 3;
if new1[i]-new2[i]=1 then hcc=vname(new1[i]);
end;
run;
t*******s
发帖数: 289
3
Thanks much. Totally there are 254 HCC. Do you mind revising your codes for
references?

【在 l****u 的大作中提到】
: I did not check.
: data t3;
: merge t1 t2(rename=(hcc1=hcc4 hcc2=hcc5 hcc3=hcc6));
: by id;
: array new1 [3] hcc1 hcc2 hcc3;
: array new2 [3] hcc4 hcc5 hcc6;
: do i=1 to 3;
: if new1[i]-new2[i]=1 then hcc=vname(new1[i]);
: end;
: run;

l****u
发帖数: 529
4
In 254 hccis, only one gets 1 in t1 and 0 in t2? In case there are more
HCCis per ID that meet your requirement, I modified the code to get more
observations for each id.
I did not check the code. The logic should be correct.
%macro t;
data t3
merge t1 t2(rename=(%do i=1 %to 254;
hcc&i.=c&i.
%end;));
by id;
array new1 [254] hcc1-hcc254;
array new2 [254] c1-c254;
do i=1 to 254;
if new1[i]-new2[i]=1 then do;
hcc=vname(new1[i]);
output;
end;
end;
run;
%mend;
%t
t*******s
发帖数: 289
5
there can be more than one HCC that meets the criteria for each ID, if that
is what you ask. Thanks a lot for your responses and very smart input

【在 l****u 的大作中提到】
: In 254 hccis, only one gets 1 in t1 and 0 in t2? In case there are more
: HCCis per ID that meet your requirement, I modified the code to get more
: observations for each id.
: I did not check the code. The logic should be correct.
: %macro t;
: data t3
: merge t1 t2(rename=(%do i=1 %to 254;
: hcc&i.=c&i.
: %end;));
: by id;

1 (共1页)
进入Statistics版参与讨论
相关主题
my revised resume请教:三道SAS BASE题
[合集] 问个SAS的问题问一个sas改大量的variable name的问题
sas email问个SAS问题
请教一个SAS Macro问题。谢谢SAS Question
mysql 问题问一个简单的SAS问题,多谢
a SAS problem怎么用SAS sort 50G的data
如何在用SAS给多个data step 和proc step 做循环语句呢?SAS 求助:如何根据变量值输出变量名
请问如何把一个数据里所有的变量名后面都加个v?thanks.请教这个怎么用SAS简单实现
相关话题的讨论汇总
话题: hcc1话题: hcc3话题: hcc2话题: hcci话题: table