BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dht115
Calcite | Level 5

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: 

 

dht115_0-1641410677425.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20

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

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 510 views
  • 0 likes
  • 2 in conversation