Hi
I am trying to concatenate multiple columns bases on condition. Data is as follows.
| CRN | Diff | Pay1 | Pay2 | Pay3 | Pay4 | Pay5 | Pay6 | Pay7 | Pay8 | Pay9 | Pay10 |
| 1 | 1 | 000 | 084 | 084 | 084 | 000 | XXX | 000 | XXX | XXX | XXX |
| 2 | 10 | 065 | 000 | 000 | 000 | 000 | XXX | XXX | XXX | XXX | XXX |
| 3 | -1 | 000 | XXX | XXX | XXX | XXX | XXX | XXX | XXX | XXX | XXX |
| 4 | 3 | XXX | 000 | 000 | 000 | 000 | 000 | 000 | 000 | 000 | 000 |
| 5 | -2 | 070 | 070 | 070 | 070 | 070 | 070 | 070 | XXX | XXX | XXX |
| 6 | 1 | 090 | XXX | XXX | XXX | XXX | XXX | XXX | XXX | XXX | XXX |
The code I am using is as follows.
data temp;
set temp;
format hist $200.;
array col(*) Pay1-Pay10;
if diff=-1 then hist=catx('',col(2-10));
else if diff=-2 then hist=catx('',col(3-10));
else hist=catx('',col(*));
run;
I want concatenate column based on diff=-1 , -2 etc and concat corresponding columns.
The error I am getting is "array subscript out of range". Please help.
This is a great example of why you should look at the SAS documentation first. The documentation of the CATX function gives the proper syntax for your case.
This is a great example of why you should look at the SAS documentation first. The documentation of the CATX function gives the proper syntax for your case.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.