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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1796 views
  • 0 likes
  • 2 in conversation