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

Hi 

I am trying to concatenate multiple columns bases on condition. Data is as follows.

CRNDiffPay1Pay2Pay3Pay4Pay5Pay6Pay7Pay8Pay9Pay10
11000084084084000XXX000XXXXXXXXX
210065000000000000XXXXXXXXXXXXXXX
3-1000XXXXXXXXXXXXXXXXXXXXXXXXXXX
43XXX000000000000000000000000000
5-2070070070070070070070XXXXXXXXX
61090XXXXXXXXXXXXXXXXXXXXXXXXXXX

 

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.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

Register now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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