<?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: proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490708#M128460</link>
    <description>&lt;P&gt;Here is one last try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

/* Get the customer IDs */
create table common as
select unique A.ID, A.date
from 
    tshirt as A, 
    others as B
where A.ID=B.ID and A.date=B.date;

/* Get what they bought */
create table buys as
select a.id, a.date, a.cloth 
from tshirt as a inner join common as b on a.id=b.id and a.date=b.date
union
select a.id, a.date, a.cloth
from others as a inner join common as b on a.id=b.id and a.date=b.date
order by id, date, cloth;
quit;

/* Transform list into a table */
proc transpose data=buys out=buysTable(drop=_name_)
prefix=cloth;
by id date;
var cloth;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 29 Aug 2018 03:21:48 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-08-29T03:21:48Z</dc:date>
    <item>
      <title>proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490566#M128369</link>
      <description>&lt;P&gt;&lt;BR /&gt;data tshirt;&lt;BR /&gt;input @1 id $5. @7 cloth $6. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/189370"&gt;@14&lt;/a&gt; receipt_number $3. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71462"&gt;@18&lt;/a&gt; date mmddyy10.;&lt;BR /&gt;format date mmddyy10. ;&lt;BR /&gt;datalines;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;12345 tshirt 22x 08/23/2018&lt;BR /&gt;12345 tshirt 23x 08/23/2018&lt;BR /&gt;12345 tshirt 24x 09/24/2018&lt;BR /&gt;12345 tshirt 25x 09/24/2018&lt;BR /&gt;12346 tshirt 22y 08/23/2018&lt;BR /&gt;12346 tshirt 23y 08/24/2018&lt;BR /&gt;12347 tshirt 25z 09/25/2018&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data others;&lt;BR /&gt;input @1 id $5. @7 cloth $6. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/189370"&gt;@14&lt;/a&gt; receipt_number $3. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71462"&gt;@18&lt;/a&gt; date mmddyy10.;&lt;BR /&gt;format date mmddyy10. ;&lt;BR /&gt;datalines;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;12345 perfum 23x 08/23/2018 &amp;nbsp;&lt;BR /&gt;12345 perfum 24x 08/23/2018 &amp;nbsp;&lt;BR /&gt;12347 perfum 25z 09/25/2018&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;12347 cologn 26z 09/25/2018&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*Question: who bought shirts and other stuff from 'others' data set on the same date?;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table common as&lt;BR /&gt;select A.*, B.*&lt;BR /&gt;from tshirt A, others B&lt;BR /&gt;where A.ID = B.ID and A.date=B.date;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I am not getting what I want. Please help.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 18:06:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490566#M128369</guid>
      <dc:creator>Pooja2</dc:creator>
      <dc:date>2018-08-28T18:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490567#M128370</link>
      <description>What is your expected output based on the data shown?</description>
      <pubDate>Tue, 28 Aug 2018 18:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490567#M128370</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-28T18:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490634#M128413</link>
      <description>&lt;P&gt;What you got is the cartesian product of the two subsets for each ID and date. You would want&amp;nbsp; something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

/* Get the customer IDs */
create table common as
select unique A.ID, A.date
from 
    tshirt as A, 
    others as B
where A.ID=B.ID and A.date=B.date;

/* Get what they bought */
create table buys as
select a.id, a.date, a.cloth, a.receipt_number 
from tshirt as a inner join common as b on a.id=b.id and a.date=b.date
union all
select a.id, a.date, a.cloth, a.receipt_number 
from others as a inner join common as b on a.id=b.id and a.date=b.date
order by id, date;

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Aug 2018 21:34:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490634#M128413</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-08-28T21:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490705#M128457</link>
      <description>&lt;P&gt;I want one row for one ID and what that ID bought in separate columns. Also, there are only one option for cloth in tshirt data and three options for cloth in others dataset.&amp;nbsp; if possible, something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cloth1&amp;nbsp; cloth2&amp;nbsp; &amp;nbsp; &amp;nbsp; cloth3&lt;/P&gt;&lt;P&gt;12345&amp;nbsp;&amp;nbsp; 08/23/2018&amp;nbsp;&amp;nbsp;&amp;nbsp; tshirt&amp;nbsp; perfume&lt;/P&gt;&lt;P&gt;12347&amp;nbsp;&amp;nbsp; 09/25/2018&amp;nbsp;&amp;nbsp;&amp;nbsp; tshirt&amp;nbsp; perfume&amp;nbsp; cologne&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 03:12:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490705#M128457</guid>
      <dc:creator>Pooja2</dc:creator>
      <dc:date>2018-08-29T03:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490708#M128460</link>
      <description>&lt;P&gt;Here is one last try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

/* Get the customer IDs */
create table common as
select unique A.ID, A.date
from 
    tshirt as A, 
    others as B
where A.ID=B.ID and A.date=B.date;

/* Get what they bought */
create table buys as
select a.id, a.date, a.cloth 
from tshirt as a inner join common as b on a.id=b.id and a.date=b.date
union
select a.id, a.date, a.cloth
from others as a inner join common as b on a.id=b.id and a.date=b.date
order by id, date, cloth;
quit;

/* Transform list into a table */
proc transpose data=buys out=buysTable(drop=_name_)
prefix=cloth;
by id date;
var cloth;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Aug 2018 03:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/490708#M128460</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-08-29T03:21:48Z</dc:date>
    </item>
  </channel>
</rss>

