<?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: Simplify joins in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279705#M56402</link>
    <description>&lt;P&gt;Transpose the partners dataset into long format first, then do the join. Don't keep data (number of partner) in structure (column name).&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2016 10:51:08 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-06-23T10:51:08Z</dc:date>
    <item>
      <title>Simplify joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279702#M56400</link>
      <description>&lt;P&gt;There are 2 datasets, names and partners. In partners , id is given but we need to find corresponding names using "names" dataset&lt;/P&gt;&lt;P&gt;data names;&lt;BR /&gt;input st_id st_names $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 John&lt;BR /&gt;2 Mark&lt;BR /&gt;3 Steve&lt;BR /&gt;4 Smith&lt;BR /&gt;5 Cook&lt;BR /&gt;6 Messi&lt;BR /&gt;7 Mary&lt;BR /&gt;8 Kris&lt;BR /&gt;9 Kevin&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data partners;&lt;BR /&gt;input st_id1 st_id2 st_id3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 4 7&lt;BR /&gt;2 5 8&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;I need to add 3 columns in dataset partners name_id1,name_id2,name_id3 . To get names from dataset "names" as per id , i think we need to join dataset 3 times. What if datasets has million of records, is there any way we can simply the joins?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 10:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279702#M56400</guid>
      <dc:creator>Ps8813</dc:creator>
      <dc:date>2016-06-23T10:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Simplify joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279704#M56401</link>
      <description>&lt;P&gt;How does parteners dataset relate to the first dataset? &amp;nbsp;I am confused as there are three name fields in it, but a name could only have one partner no? &amp;nbsp;If we assume the the first column is the person matching st_id then:&lt;/P&gt;
&lt;PRE&gt;data names;
input st_id st_names $;
datalines;
1 John
2 Mark
3 Steve
4 Smith
5 Cook
6 Messi
7 Mary
8 Kris
9 Kevin
;
run;

data partners;
input st_id1 st_id2 st_id3;
datalines;
1 4 7
2 5 8
;
run;

proc sql;
  create table WANT as
  select  A.*,
          (select ST_NAMES from NAMES where ST_ID=B.ST_ID2) as ST_NAME2,
          (select ST_NAMES from NAMES where ST_ID=B.ST_ID3) as ST_NAME3
  from    NAMES A
  left join PARTNERS B
  on      A.ST_ID=B.ST_ID1;
quit;
&lt;/PRE&gt;
&lt;P&gt;But that only gives the first two records two partners?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 10:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279704#M56401</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-23T10:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Simplify joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279705#M56402</link>
      <description>&lt;P&gt;Transpose the partners dataset into long format first, then do the join. Don't keep data (number of partner) in structure (column name).&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 10:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279705#M56402</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-23T10:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Simplify joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279707#M56403</link>
      <description>&lt;P&gt;In actual scenario, names dataset has 80000 + records and partners has million of records , so cant do the transpose.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 10:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279707#M56403</guid>
      <dc:creator>Ps8813</dc:creator>
      <dc:date>2016-06-23T10:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Simplify joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279711#M56404</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71683"&gt;@Ps8813&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;In actual scenario, names dataset has 80000 + records and partners has million of records , so cant do the transpose.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And?&lt;/P&gt;
&lt;P&gt;A puny little million is no problem for SAS.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 11:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279711#M56404</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-23T11:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Simplify joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279720#M56409</link>
      <description>&lt;P&gt;Create a format out of names dataset and then apply format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data fmt_def;&lt;/P&gt;
&lt;P&gt;set table1;&lt;/P&gt;
&lt;P&gt;fmtname='name_fmt';&lt;/P&gt;
&lt;P&gt;start=st_id;&lt;/P&gt;
&lt;P&gt;label=st_name;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc fmt cntlin=fmt_def;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set table2;&lt;/P&gt;
&lt;P&gt;array n_init (3) st_id1-st_id3;&lt;/P&gt;
&lt;P&gt;array n_res(3) $ st_id_name1 - st_id_name3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do i &amp;nbsp;= 1 to 3;&lt;/P&gt;
&lt;P&gt;n_res (I)= put(n_init(I), name_fmt.);&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 12:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simplify-joins/m-p/279720#M56409</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-23T12:41:21Z</dc:date>
    </item>
  </channel>
</rss>

