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

I am trying to figure out a way to concatenate a set of columns, while skipping some when the value = "no". Unfortunately because of how the entire program is structured I am unable to change the no values to null.  Please let me know.. Thanks

image.png

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Changing no to null is the easiest way, because you can then use CATX.

You could duplicate the array and then set it to missing and use that. Otherwise you need to loop and conditionally apply catx each variable.

data want;
set have;

array _col(5) _col1-_col5;
array col(5) col1-col5;
do i=1 to 5;
if col(i) ne 'no' then _col(i)=col(i);
end;
want = catx("_", of _col(*));
run;

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

Can you post as plain text for me to copy paste and test

Reeza
Super User
Changing no to null is the easiest way, because you can then use CATX.

You could duplicate the array and then set it to missing and use that. Otherwise you need to loop and conditionally apply catx each variable.

data want;
set have;

array _col(5) _col1-_col5;
array col(5) col1-col5;
do i=1 to 5;
if col(i) ne 'no' then _col(i)=col(i);
end;
want = catx("_", of _col(*));
run;
dane7722
Fluorite | Level 6

Thank you!!

mohdfaisal89
Calcite | Level 5

Please Help !

 

I want to concatenate all the columns ending with _A in a table. I have more then 60 columns ending with _A in a table 90 columns

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 4 replies
  • 2904 views
  • 0 likes
  • 4 in conversation