<?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: Combining two proc sql with count in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combining-two-proc-sql-with-count/m-p/768050#M243571</link>
    <description>&lt;P&gt;Since you create two separate datasets, you cannot combine this; you can only create one dataset in a single CREATE TABLE statement.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Sep 2021 08:29:16 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-09-16T08:29:16Z</dc:date>
    <item>
      <title>Combining two proc sql with count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-two-proc-sql-with-count/m-p/768045#M243568</link>
      <description>&lt;P&gt;Hi I need help in combining the below two proc sql statements into 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data HAVE;
input user_type : $20. Saved policy_no username : $20.;
datalines;
R 1 1 ALUPIYA
R 1 1 ALUPIYA
R 0 2 ALUPIYA
R 1 3 ALUPIYA
I 0 5 DLOUIS
I 1 4 DLOUIS
I 1 4 DLOUIS
O 1 6 DMORAKE
O 1 7 DMORAKE
O 1 8 DMORAKE
O 0 9 DMORAKE

;


data WANT;
input user_type : $20. Total_Saved Total_policies username : $20.;
datalines;
R 2 3 ALUPIYA
I 1 2 DLOUIS
O 3 4 DMORAKE
;

proc sql; 
create table Saves as 
select  user_type,
        username,
        count(distinct policy_no) as total_saved
        from HAVE
		where saved = 1
		group by 1,2
		order by 2
;quit;

proc sql; create table policies_total as
  select user_type,
         username,
         count(distinct policy_no) as Total_Policies
    from HAVE
group by 1,2
order by 2;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 08:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-two-proc-sql-with-count/m-p/768045#M243568</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2021-09-16T08:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Combining two proc sql with count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-two-proc-sql-with-count/m-p/768050#M243571</link>
      <description>&lt;P&gt;Since you create two separate datasets, you cannot combine this; you can only create one dataset in a single CREATE TABLE statement.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 08:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-two-proc-sql-with-count/m-p/768050#M243571</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-16T08:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Combining two proc sql with count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-two-proc-sql-with-count/m-p/768051#M243572</link>
      <description>Hi Kurt, I have only one dataset which is HAVE..all I need is to have total_saved, total_policies,username, user_type in one dataset</description>
      <pubDate>Thu, 16 Sep 2021 08:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-two-proc-sql-with-count/m-p/768051#M243572</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2021-09-16T08:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Combining two proc sql with count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-two-proc-sql-with-count/m-p/768052#M243573</link>
      <description>&lt;P&gt;Use the solution I gave you &lt;A href="https://communities.sas.com/t5/SAS-Programming/Using-count-function-with-CASE/m-p/767873#M243497" target="_blank" rel="noopener"&gt;here&lt;/A&gt;. Just add user_type to the BY statement.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 08:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-two-proc-sql-with-count/m-p/768052#M243573</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-16T08:33:17Z</dc:date>
    </item>
  </channel>
</rss>

