<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: conditional  concatenate Failure reasons in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/conditional-concatenate-Failure-reasons/m-p/761743#M241083</link>
    <description>&lt;P&gt;One way to go:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc format;
  value Reason1FFF
    1='Reason A'
    other=' '
  ;
  value Reason2FFF
    1='Reason B'
    other=' '
  ;
  value Reason3FFF
    1='Reason C'
    other=' '
  ;
  value Reason4FFF
    1='Reason D'
    other=' '
  ;
run;

data have;
  format reason1 reason1fff.  reason2 reason2fff. reason3 reason3fff.  reason4 reason4fff.;
  input id reason1 reason2 reason3 reason4;
  cards;
1 0 0 0 0
2 1 1 0 0
3 0 1 0 1
4 0 0 0 1
5 0 0 0 0 
6 1 1 1 1 
7 0 0 1 1
8 0 0 0 0 
9 1 0 0 0
;
run;

data want;
  set have;
  reason=catx(',', 
              put(reason1,reason1fff.),
              put(reason2,reason2fff.),
              put(reason3,reason3fff.),
              put(reason4,reason4fff.)
             );
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Aug 2021 07:50:40 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-08-16T07:50:40Z</dc:date>
    <item>
      <title>conditional  concatenate Failure reasons</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-concatenate-Failure-reasons/m-p/761731#M241076</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;For each customer ID I have 4 binary variables (with values 1/0) .&lt;/P&gt;
&lt;P&gt;Each binary variable represent reason for failure.&lt;/P&gt;
&lt;P&gt;It might happen that there are multiple reasons for failure .&lt;/P&gt;
&lt;P&gt;My task is to create a new variable called "Vector" that will concatenate reasons for failure.&lt;/P&gt;
&lt;P&gt;Expected values will be :&lt;/P&gt;
&lt;P&gt;For ID=1&amp;nbsp; &amp;nbsp; &amp;nbsp; will get Null value&lt;/P&gt;
&lt;P&gt;For&amp;nbsp; ID=2 will get&amp;nbsp; 'Reason A ,Reason B'&lt;/P&gt;
&lt;P&gt;For&amp;nbsp; ID=3 will get&amp;nbsp; 'Reason B ,Reason D'&lt;/P&gt;
&lt;P&gt;For&amp;nbsp; ID=4 will get&amp;nbsp; 'Reason D'&lt;/P&gt;
&lt;P&gt;and so on&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;P&gt;I know to concatenate but in this case need conditional&amp;nbsp;&amp;nbsp;concatenate&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc format ;
value Reason1FFF
1='Reason A'
0='No Failure'
;
Run;

Proc format ;
value Reason2FFF
1='Reason B'
0='No Failure'
;
Run;

Proc format ;
value Reason3FFF
1='Reason C'
0='No Failure'
;
Run;


Proc format ;
value Reason4FFF
1='Reason D'
0='No Failure'
;
Run;



Data have;
Format Reason1 Reason1FFF.  Reason2 Reason2FFF. Reason3 Reason3FFF.  Reason4 Reason4FFF.;
Input ID Reason1 Reason2 Reason3 Reason4;
Cards;
1 0 0 0 0
2 1 1 0 0
3 0 1 0 1
4 0 0 0 1
5 0 0 0 0 
6 1 1 1 1 
7 0 0 1 1
8 0 0 0 0 
9 1 0 0 0
;
Run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Aug 2021 04:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-concatenate-Failure-reasons/m-p/761731#M241076</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-08-16T04:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: conditional  concatenate Failure reasons</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-concatenate-Failure-reasons/m-p/761733#M241078</link>
      <description>&lt;P&gt;Then call catx conditionally or change the formats to return missing instead of "no failure".&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 05:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-concatenate-Failure-reasons/m-p/761733#M241078</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-08-16T05:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: conditional  concatenate Failure reasons</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-concatenate-Failure-reasons/m-p/761743#M241083</link>
      <description>&lt;P&gt;One way to go:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc format;
  value Reason1FFF
    1='Reason A'
    other=' '
  ;
  value Reason2FFF
    1='Reason B'
    other=' '
  ;
  value Reason3FFF
    1='Reason C'
    other=' '
  ;
  value Reason4FFF
    1='Reason D'
    other=' '
  ;
run;

data have;
  format reason1 reason1fff.  reason2 reason2fff. reason3 reason3fff.  reason4 reason4fff.;
  input id reason1 reason2 reason3 reason4;
  cards;
1 0 0 0 0
2 1 1 0 0
3 0 1 0 1
4 0 0 0 1
5 0 0 0 0 
6 1 1 1 1 
7 0 0 1 1
8 0 0 0 0 
9 1 0 0 0
;
run;

data want;
  set have;
  reason=catx(',', 
              put(reason1,reason1fff.),
              put(reason2,reason2fff.),
              put(reason3,reason3fff.),
              put(reason4,reason4fff.)
             );
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Aug 2021 07:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-concatenate-Failure-reasons/m-p/761743#M241083</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-08-16T07:50:40Z</dc:date>
    </item>
  </channel>
</rss>

