<?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: concatenating of multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386006#M92413</link>
    <description>&lt;P&gt;Its been mentioned time and time again, post test data in the form of a datastep, as text in the post, and show what output you want.&lt;/P&gt;
&lt;P&gt;What do you want the output when all four are present, all cat'd? &amp;nbsp;If so then:&lt;/P&gt;
&lt;PRE&gt;catx(',',of screas:);&lt;/PRE&gt;
&lt;P&gt;Should be fine, if it is only pairs, what is the precedence? &amp;nbsp;Should it be Loc: &amp;lt;reas1&amp;gt;,&amp;lt;reas 2&amp;gt; etc.?&lt;/P&gt;</description>
    <pubDate>Mon, 07 Aug 2017 13:40:15 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-08-07T13:40:15Z</dc:date>
    <item>
      <title>concatenating of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386001#M92410</link>
      <description>&lt;P&gt;I need to concatenate 2 or more variables if both are present like below&lt;/P&gt;
&lt;P&gt;%if SECREAS1 ne '' and SECREAS2 ne '' %then %do;&lt;BR /&gt; sec_reasons=catx(';', SECREAS1,SECREAS2);&lt;BR /&gt; %end;&lt;BR /&gt; &lt;BR /&gt; %if SECREAS1 ne '' and SECREAS2 eq '' %then %do;&lt;BR /&gt; sec_reasons=SECREAS1;&lt;BR /&gt; %end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if i have another reason like SECREAS3 and&amp;nbsp;&lt;SPAN&gt;SECREAS4 then it will be more complex to do. is there any better way to do.&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE width="624"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;subj&lt;/TD&gt;
&lt;TD width="140"&gt;SECREAS1&lt;/TD&gt;
&lt;TD width="140"&gt;SECREAS2&lt;/TD&gt;
&lt;TD width="140"&gt;SECREAS3&lt;/TD&gt;
&lt;TD width="140"&gt;SECREAS4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;101&lt;/TD&gt;
&lt;TD&gt;Adverse event&lt;/TD&gt;
&lt;TD&gt;Withdraw by consent&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;LOC&lt;/TD&gt;
&lt;TD&gt;Other&lt;/TD&gt;
&lt;TD&gt;LOC&lt;/TD&gt;
&lt;TD&gt;Withdraw by consent&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;103&lt;/TD&gt;
&lt;TD&gt;Withdraw by consent&lt;/TD&gt;
&lt;TD&gt;LOC&lt;/TD&gt;
&lt;TD&gt;Withdraw by consent&lt;/TD&gt;
&lt;TD&gt;Other&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 13:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386001#M92410</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-08-07T13:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386006#M92413</link>
      <description>&lt;P&gt;Its been mentioned time and time again, post test data in the form of a datastep, as text in the post, and show what output you want.&lt;/P&gt;
&lt;P&gt;What do you want the output when all four are present, all cat'd? &amp;nbsp;If so then:&lt;/P&gt;
&lt;PRE&gt;catx(',',of screas:);&lt;/PRE&gt;
&lt;P&gt;Should be fine, if it is only pairs, what is the precedence? &amp;nbsp;Should it be Loc: &amp;lt;reas1&amp;gt;,&amp;lt;reas 2&amp;gt; etc.?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 13:40:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386006#M92413</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-07T13:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386015#M92419</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if SECREAS1 ne '' and SECREAS2 ne '' %then %do;
sec_reasons=catx(';', SECREAS1,SECREAS2);
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;an interesting mixture of datastep and macro code, most likely not working as expected.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 13:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386015#M92419</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-08-07T13:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386019#M92421</link>
      <description>&lt;P&gt;i do not have test data for this case but making a code which can work on any number of condtions.&lt;/P&gt;
&lt;P&gt;the below one suggested by you works well&lt;/P&gt;
&lt;PRE&gt;catx(',',of screas:);&lt;/PRE&gt;
&lt;P&gt;but i am thinking how can i control the %if conditions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i have value only in sec_reason1 then it should be displayed as it is but if i have values in sec_reason1 and sec_reason2 then it should concatenate with semicolon in middle the same if we have values in the rest of sec_reasons3 or 4(in case if we have).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 14:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386019#M92421</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-08-07T14:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386026#M92422</link>
      <description>&lt;P&gt;%if is macro language, nothing to do with datastep language, they are very different and for different purposes. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are making general code for a library or something like that then you will have a functional design specification document which clearly shows all inputs outputs, explains logic, program flow, checks performed etc. &amp;nbsp;So you should have a good idea of the inputs you will get. &amp;nbsp;The cat functions will only concatenate when there is a value present, but that might not cover all eventualities.&lt;/P&gt;
&lt;P&gt;Another point, why do you have SCREAS1-x. &amp;nbsp;In standard CDISC models screen fail reasons would be held in SUPPDS domain as:&lt;/P&gt;
&lt;P&gt;QNAM &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; QVAL&lt;/P&gt;
&lt;P&gt;SCRNREAS &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And this would only capture where there is data, so to get a complete list of reason you would do:&lt;/P&gt;
&lt;PRE&gt;data want;
  set suppds (where=(qnam="SCRNREAS"));
  by usubjid;
  length reas $2000;
  reas=ifc(first.usubjid,qval,catx(';',reas,qval));
  if last.usubjid then output;
run;&lt;/PRE&gt;
&lt;P&gt;Or combine that somehow into existing domain modelling code.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 14:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenating-of-multiple-variables/m-p/386026#M92422</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-07T14:20:51Z</dc:date>
    </item>
  </channel>
</rss>

