<?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: Vertical Joining in the same dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608618#M17713</link>
    <description>&lt;P&gt;Questions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Are the data column values always in alphabetic order?&amp;nbsp; (i.e. can you have B A B for a given ID?).&lt;/LI&gt;
&lt;LI&gt;If they are not in alphabetic order, do you care whether the desired output honors the order the 3 values started out with?&amp;nbsp; (i.e. from B A B, do you care whether the output is B A&amp;nbsp; vs A B?)&lt;/LI&gt;
&lt;LI&gt;Could you set up your sample data in a data step, the better to help us help you?&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Mon, 02 Dec 2019 04:45:35 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2019-12-02T04:45:35Z</dc:date>
    <item>
      <title>Vertical Joining in the same dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608617#M17712</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to join 3 variables in a data set which is measuring the same thing - hence I would only like a new variable with all the information from the columns and no duplicates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data I have:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; 1&amp;nbsp; 2&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; A&amp;nbsp; A&amp;nbsp; B&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; A&amp;nbsp; B&amp;nbsp; C&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; A&amp;nbsp; A&amp;nbsp; A&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; A&amp;nbsp; B&amp;nbsp; B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data I want:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; New_Var&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; A&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; B&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; A&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; B&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; C&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; A&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; A&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone can please help me, that'd be great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 04:38:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608617#M17712</guid>
      <dc:creator>Bounce</dc:creator>
      <dc:date>2019-12-02T04:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical Joining in the same dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608618#M17713</link>
      <description>&lt;P&gt;Questions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Are the data column values always in alphabetic order?&amp;nbsp; (i.e. can you have B A B for a given ID?).&lt;/LI&gt;
&lt;LI&gt;If they are not in alphabetic order, do you care whether the desired output honors the order the 3 values started out with?&amp;nbsp; (i.e. from B A B, do you care whether the output is B A&amp;nbsp; vs A B?)&lt;/LI&gt;
&lt;LI&gt;Could you set up your sample data in a data step, the better to help us help you?&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 02 Dec 2019 04:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608618#M17713</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-12-02T04:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical Joining in the same dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608619#M17714</link>
      <description>&lt;P&gt;Hi mkeintz, thanks for your reply.&lt;BR /&gt;&lt;BR /&gt;1. No the column values are completely random, they are actually in the format of dates in the dataset I am using.&lt;/P&gt;&lt;P&gt;2. No the order of the output does not matter since I can sort them later - just need them all in one column.&lt;/P&gt;&lt;P&gt;3. Sorry do you mean this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA Example;&lt;BR /&gt;format ID 1.&lt;BR /&gt;VAR1 VAR2 VAR3 $1.;&lt;BR /&gt;input ID VAR1 VAR2 VAR3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 A A A&lt;BR /&gt;2 A B C&lt;BR /&gt;3 A A A&lt;BR /&gt;4 A B B&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 05:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608619#M17714</guid>
      <dc:creator>Bounce</dc:creator>
      <dc:date>2019-12-02T05:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical Joining in the same dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608640#M17719</link>
      <description>&lt;P&gt;Run a transpose:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose
  data=example
  out=want (rename=(col1=new_var))
;
by id;
var var:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Dec 2019 08:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608640#M17719</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-02T08:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical Joining in the same dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608650#M17721</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/267739"&gt;@Bounce&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this code (proc transpose + proc sort to remove duplicate records):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=example out=want (rename=(col1=New_Var) drop=_name_);
	by id;
	var var:;
run;

proc sort data=want nodupkey;
	by id New_Var;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Capture d’écran 2019-12-02 à 10.36.21.png" style="width: 146px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34366i70471ABE27CA3E08/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2019-12-02 à 10.36.21.png" alt="Capture d’écran 2019-12-02 à 10.36.21.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 09:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608650#M17721</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-02T09:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical Joining in the same dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608893#M17778</link>
      <description>&lt;P&gt;There is a one-step solution, which&amp;nbsp; benefits from the CALL SORTC subroutine:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Example;
  format ID 1.  VAR1 VAR2 VAR3 $1.;
  input ID VAR1 VAR2 VAR3;
datalines;
1 A A A
2 A B C
3 A A A
4 A B B
run;

data want (keep=id var);
  set example;
  array  _v {*} dummy var1-var3;
  call sortc(of _v{*});
  do i=2 to dim(_v);
    if missing(_v{i}) then continue;
    var=_v{i};
    if var^=_v{i-1} then output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The "if missing(_v{i}) then continue statement skips to the next iteration of the do loop, skipping the later output stateement.&lt;/LI&gt;
&lt;LI&gt;I put&amp;nbsp; a dummy variable at the lower bound&amp;nbsp; of the array, to smiplify the&amp;nbsp; "if var^=_v{i-1}" test.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 02 Dec 2019 23:36:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-Joining-in-the-same-dataset/m-p/608893#M17778</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-12-02T23:36:50Z</dc:date>
    </item>
  </channel>
</rss>

