<?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 New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588246#M14775</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240933"&gt;@jaiganesh&lt;/a&gt;&amp;nbsp; You need another pass I am afraid in SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Product :$20.    Location;
cards;
0025743    475
0025743    109
0R4007    109
0R4007    109
;

proc sql;
create table want as
select a.*, count
from have a, (select *,count(*) as count from have group by product,location)b
where a.product=b.product and a.location=b.location;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 12 Sep 2019 14:06:02 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-09-12T14:06:02Z</dc:date>
    <item>
      <title>Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588218#M14769</link>
      <description>&lt;P&gt;Hello Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find input below.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Product&amp;nbsp; &amp;nbsp; Location&lt;BR /&gt;0025743&amp;nbsp; &amp;nbsp; 475&lt;BR /&gt;0025743&amp;nbsp; &amp;nbsp; 109&lt;BR /&gt;0R4007&amp;nbsp; &amp;nbsp; 109&lt;BR /&gt;0R4007&amp;nbsp; &amp;nbsp; 109&lt;/P&gt;&lt;P&gt;I'm looking for out the the combine (Product &amp;amp; Location Variable) distinct count. Output i'm expecting is :&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Product&amp;nbsp; &amp;nbsp; Location count&lt;BR /&gt;0025743&amp;nbsp; &amp;nbsp; 475&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;0025743&amp;nbsp; &amp;nbsp;109&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;0R4007&amp;nbsp; &amp;nbsp; 109&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 (As i've product and location same)&lt;BR /&gt;0R4007&amp;nbsp; &amp;nbsp; 109&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 (As i've product and location same)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can one please help to get this done with proc sql.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 13:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588218#M14769</guid>
      <dc:creator>jaiganesh</dc:creator>
      <dc:date>2019-09-12T13:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588220#M14770</link>
      <description>&lt;P&gt;I don't follow this logic. Why is count=1 for Product=&lt;SPAN&gt;0025743 and 2 for&amp;nbsp;0R4007?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 13:44:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588220#M14770</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-09-12T13:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588232#M14771</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Count=1 for Product=0025743&amp;nbsp; because we are looking for the Distinct count of Product and Location Variable. Here Product&amp;nbsp;0025743&amp;nbsp; has appeared&amp;nbsp; twice but the independent Location, Hence Each entry could be calculated as Count 1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you follow this logic then,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Product 0R4007 with Location 109&amp;nbsp; has appeared twice in the table, Hence Count is 2.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm looking for SQL help on this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 13:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588232#M14771</guid>
      <dc:creator>jaiganesh</dc:creator>
      <dc:date>2019-09-12T13:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588235#M14772</link>
      <description>&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; create table want as&lt;BR /&gt;&amp;nbsp; select Product,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Location,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(location) as count&lt;BR /&gt;&amp;nbsp;&amp;nbsp; from have&lt;BR /&gt;&amp;nbsp;&amp;nbsp; group by Product, Location;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 13:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588235#M14772</guid>
      <dc:creator>Aku</dc:creator>
      <dc:date>2019-09-12T13:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588241#M14773</link>
      <description>&lt;P&gt;Welcome to the forums&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289881"&gt;@Aku&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe your answer will only return one of the lines for the last record rather than the two lines?&lt;/P&gt;
&lt;P&gt;I think you would need to remerge it here. Oddly, if there were another variable this wouldn't be an issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289881"&gt;@Aku&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; create table want as&lt;BR /&gt;&amp;nbsp; select Product,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Location,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(location) as count&lt;BR /&gt;&amp;nbsp;&amp;nbsp; from have&lt;BR /&gt;&amp;nbsp;&amp;nbsp; group by Product, Location;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 14:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588241#M14773</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-12T14:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588242#M14774</link>
      <description>&lt;P&gt;Yes 3rd variable is making problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This logic is not sufficient for more then 2 variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 14:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588242#M14774</guid>
      <dc:creator>jaiganesh</dc:creator>
      <dc:date>2019-09-12T14:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588246#M14775</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240933"&gt;@jaiganesh&lt;/a&gt;&amp;nbsp; You need another pass I am afraid in SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Product :$20.    Location;
cards;
0025743    475
0025743    109
0R4007    109
0R4007    109
;

proc sql;
create table want as
select a.*, count
from have a, (select *,count(*) as count from have group by product,location)b
where a.product=b.product and a.location=b.location;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Sep 2019 14:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588246#M14775</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-12T14:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588267#M14780</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240933" target="_blank"&gt;@jaiganesh&lt;/A&gt;&amp;nbsp; And if you really want to remerge, you'd still need an extra-pass like the below to have a junk extra var created but it doesn't look good when you can handle with an in-line view and join your "have" as demonstrated above,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;
&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; Product :&lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;20&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;    Location&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;
0025743    475
0025743    109
0R4007    109
0R4007    109
&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; temp&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sql&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
create &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;drop&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as
&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as &lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; temp
&lt;SPAN class="token keyword"&gt;group&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; product&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;location&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;quit&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 14:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588267#M14780</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-12T14:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588273#M14781</link>
      <description>&lt;P&gt;Alternatively if you would like to try a data step as well&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=want;
by Product Location;
run;

data want2;
do until(last.Location);
set want;
by Product Location;
retain cnt;
if first.Location then cnt=1;
else cnt+1;
end;
do until(last.Location);
set want;
by Product Location;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Sep 2019 14:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588273#M14781</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-12T14:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588468#M14799</link>
      <description>Count of the combination of product &amp;amp; location...</description>
      <pubDate>Fri, 13 Sep 2019 10:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-SQL/m-p/588468#M14799</guid>
      <dc:creator>dvart1</dc:creator>
      <dc:date>2019-09-13T10:41:44Z</dc:date>
    </item>
  </channel>
</rss>

