We have a SAS data set:
One
-----
X
5,6,1,10
2,3
4,7,8
9
We have to create SAS data set Two:
Two
-------
X a1 a2 a3 a4 a5 a6 a7 a8 a9 a10
------- ---------------------------------
5,6,1,10 1 0 0 0 5 6 0 0 0 10
2,3 0 2 3 0 0 0 0 0 0 0
4,7,8 0 0 0 4 0 0 7 8 0 0
9 0 0 0 0 0 0 0 0 9 0
Variables: X A1-A10
I will always appreciate most efficient SAS program which is taking the least resources.
Now prepare your Base SAS and
Advance SAS Certification Exams with Online Mock tests: http://exam.sankhyana.com
For training related info kindly mail us at info@sankhyana.com
www.sankhyana.com
One
-----
X
5,6,1,10
2,3
4,7,8
9
We have to create SAS data set Two:
Two
-------
X a1 a2 a3 a4 a5 a6 a7 a8 a9 a10
------- ---------------------------------
5,6,1,10 1 0 0 0 5 6 0 0 0 10
2,3 0 2 3 0 0 0 0 0 0 0
4,7,8 0 0 0 4 0 0 7 8 0 0
9 0 0 0 0 0 0 0 0 9 0
Variables: X A1-A10
I will always appreciate most efficient SAS program which is taking the least resources.
Now prepare your Base SAS and
Advance SAS Certification Exams with Online Mock tests: http://exam.sankhyana.com
For training related info kindly mail us at info@sankhyana.com
www.sankhyana.com
data one;
ReplyDeleteinput X $;
cards;
5,6,1,10
2,3
4,7,8
9
;
run;
data two;
set one;
array list (*) $8 a1-a10;
do i=1 to 4;
val = scan(x,i,',');
if val ne '' then list[val]=val;
end;
do i=1 to dim(list);
if list[i] = '' then list[i]='0';
end;
drop i val;
run;