🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 10-30-2018 02:20 PM
(3595 views)
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
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
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;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Can you post as plain text for me to copy paste and test
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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