我有一個表,其中行是一個標識符,並且列標記如下所示。查找具有特定值的數據集中列的索引
ID C1 C2 C3 C4 C5 C6 C7 C8 C9 C10
17028 0 1 0 0 0 1 0 0 1 0
17030 1 1 1 0 1 0 0 0 1 0
17037 0 1 0 0 0 0 0 1 1 0
17040 1 1 0 0 1 0 0 0 1 0
17041 0 1 0 0 0 0 1 0 1 0
對於每一行,我想其表示與值的變量= 1
這是我使用的代碼的級聯名或索引,但是在高效似乎有點雖然一個標誌完成工作。
data temp71;
set temp7;
format flag 20.;
flag=0;
if c1= 1 then flag=flag+1000000000000000;
if c2= 1 then flag=flag+100000000000000;
if c3= 1 then flag=flag+10000000000000;
if c4= 1 then flag=flag+1000000000000;
if c5= 1 then flag=flag+100000000000;
if c6= 1 then flag=flag+10000000000;
if c7= 1 then flag=flag+1000000000;
if c8= 1 then flag=flag+100000000;
if c9= 1 then flag=flag+10000000;
if c10= 1 then flag=flag+1000000;
if c11= 1 then flag=flag+100000;
if c12= 1 then flag=flag+10000;
if c13= 1 then flag=flag+1000;
if c14= 1 then flag=flag+100;
if c15= 1 then flag=flag+10;
if c16= 1 then flag=flag+1;
run;
@Tom我已經包含了我試過的代碼。 – Yuvaraj