In following example, I want to assigned test1 value to try1, test2 value to try2, test3 value to try3.
DATA have;
input IDnumber $ test1 test2 test3;
datalines;
aa 1 0 0
bb 0 0 0
cc 0 0 1
dd 1 1 1
;
RUN;
DATA want;
set have;
array try {3};
RUN;
I tried following, but did not work.
Data want;
Set have;
Array try(3) test1-test3;
Run;
Desire output should be:
DATA want;
set have;
array try {3};
array t test1-test3;
do over t;
try(_i_)=t;
end;
RUN;
Basically, you have grouped the existing vars into an array. And what you need is another assignment array to copy the values using indexed loop sequential look up. HTH
DATA want;
set have;
array try {3};
array t test1-test3;
do over t;
try(_i_)=t;
end;
RUN;
Basically, you have grouped the existing vars into an array. And what you need is another assignment array to copy the values using indexed loop sequential look up. HTH
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.