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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.