<?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 Variables and Retain Order of Newly Concatenated Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-Variables-and-Retain-Order-of-Newly-Concatenated/m-p/625764#M184486</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1;
set mydata;
call sortc(pair_a, pair_b);
cat_pair=catx(',',pair_a,pair_b);
run;

proc freq data=data1;
table cat_pair / out = want;;
run;
 
proc print data=want;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sort your variables ahead of time.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296994"&gt;@cbourne090&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello SAS Community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am attempting to concatenate two variables, however, I would like to always retain the order of the two variables that I am concatenating because I would like to also create a table that summarizes the concatenated variables (sometimes the order is reversed [i.e. pair1,pair2 is also pair2,pair1]), but I would like to count it as 1 (irrespective of the order of the concatenated variable). Please see the sample data and what I am trying to accomplish below. I hope this makes sense. Any help is greatly appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture1.png" style="width: 679px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36226i4E6988A2EBCFF1E7/image-dimensions/679x206?v=v2" width="679" height="206" role="button" title="Picture1.png" alt="Picture1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS CODE TO CONCATENATE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data data1;&lt;/P&gt;
&lt;P&gt;set mydata;&lt;/P&gt;
&lt;P&gt;cat_pair=catx(',',pair_a,pair_b);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Feb 2020 02:42:33 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-02-19T02:42:33Z</dc:date>
    <item>
      <title>Concatenating Variables and Retain Order of Newly Concatenated Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-Variables-and-Retain-Order-of-Newly-Concatenated/m-p/625746#M184475</link>
      <description>&lt;P&gt;Hello SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attempting to concatenate two variables, however, I would like to always retain the order of the two variables that I am concatenating because I would like to also create a table that summarizes the concatenated variables (sometimes the order is reversed [i.e. pair1,pair2 is also pair2,pair1]), but I would like to count it as 1 (irrespective of the order of the concatenated variable). Please see the sample data and what I am trying to accomplish below. I hope this makes sense. Any help is greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture1.png" style="width: 679px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36226i4E6988A2EBCFF1E7/image-dimensions/679x206?v=v2" width="679" height="206" role="button" title="Picture1.png" alt="Picture1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS CODE TO CONCATENATE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data data1;&lt;/P&gt;&lt;P&gt;set mydata;&lt;/P&gt;&lt;P&gt;cat_pair=catx(',',pair_a,pair_b);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 01:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-Variables-and-Retain-Order-of-Newly-Concatenated/m-p/625746#M184475</guid>
      <dc:creator>cbourne090</dc:creator>
      <dc:date>2020-02-19T01:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating Variables and Retain Order of Newly Concatenated Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-Variables-and-Retain-Order-of-Newly-Concatenated/m-p/625752#M184479</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select catx(',', A, B) as PAIR, count(*) as COUNT from HAVE group by 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 01:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-Variables-and-Retain-Order-of-Newly-Concatenated/m-p/625752#M184479</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-19T01:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating Variables and Retain Order of Newly Concatenated Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-Variables-and-Retain-Order-of-Newly-Concatenated/m-p/625764#M184486</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1;
set mydata;
call sortc(pair_a, pair_b);
cat_pair=catx(',',pair_a,pair_b);
run;

proc freq data=data1;
table cat_pair / out = want;;
run;
 
proc print data=want;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sort your variables ahead of time.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296994"&gt;@cbourne090&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello SAS Community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am attempting to concatenate two variables, however, I would like to always retain the order of the two variables that I am concatenating because I would like to also create a table that summarizes the concatenated variables (sometimes the order is reversed [i.e. pair1,pair2 is also pair2,pair1]), but I would like to count it as 1 (irrespective of the order of the concatenated variable). Please see the sample data and what I am trying to accomplish below. I hope this makes sense. Any help is greatly appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture1.png" style="width: 679px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36226i4E6988A2EBCFF1E7/image-dimensions/679x206?v=v2" width="679" height="206" role="button" title="Picture1.png" alt="Picture1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS CODE TO CONCATENATE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data data1;&lt;/P&gt;
&lt;P&gt;set mydata;&lt;/P&gt;
&lt;P&gt;cat_pair=catx(',',pair_a,pair_b);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 02:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-Variables-and-Retain-Order-of-Newly-Concatenated/m-p/625764#M184486</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-19T02:42:33Z</dc:date>
    </item>
  </channel>
</rss>

