<?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: remerging summary statistics with raw data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591854#M169634</link>
    <description>&lt;P&gt;The answer you got from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp; is probably the solution I would suggest for this exact query. But there may be other situations where you want to use a subquery, you can do it like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
 create table tbl as
    select  detail.*,sum.*
    from sashelp.shoes as  detail,
	               (select sum(sales) as total_sales,
		               count(* ) as Total_count 
               from sashelp.shoes) as sum

  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that as your queries get larger and more complicated, it makes thing a lot easier in the long run if you use more describing aliases than "a" and "b", in this case "detail" and "sum" seem better. I know, everybody (except yours truly) use short and cryptic aliases, but they really should not!&lt;/P&gt;</description>
    <pubDate>Thu, 26 Sep 2019 13:03:52 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2019-09-26T13:03:52Z</dc:date>
    <item>
      <title>remerging summary statistics with raw data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591778#M169586</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to remerging summary statistics with raw data.&lt;/P&gt;
&lt;P&gt;What is wrong here?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
 create table tbl as
    select  a.*,
               (select sum(sales) as total_sales,
		               count(* ) as Total_count 
               from sashelp.shoes)
    from sashelp.shoes as  a
  ;
quit;

/*ERROR: A Composite expression (usually a subquery) is used incorrectly in an expression.*/
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Sep 2019 05:18:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591778#M169586</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-09-26T05:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: remerging summary statistics with raw data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591779#M169587</link>
      <description>&lt;P&gt;Why not simply&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table tbl as
    select *, 
           sum(sales) as total_sales,
           count(*) as Total_count
    from sashelp.shoes;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Sep 2019 05:21:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591779#M169587</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-09-26T05:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: remerging summary statistics with raw data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591780#M169588</link>
      <description>He wants to merge summary statistics (sum of sales and count of rows) with the original raw data ( sashelp.shoes).&lt;BR /&gt;What you did is just calculate summary statistics without merge it back with raw data!</description>
      <pubDate>Thu, 26 Sep 2019 05:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591780#M169588</guid>
      <dc:creator>DaveStar</dc:creator>
      <dc:date>2019-09-26T05:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: remerging summary statistics with raw data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591782#M169589</link>
      <description>Sorry. I think you are right and what you wrote is remerging .Dave</description>
      <pubDate>Thu, 26 Sep 2019 05:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591782#M169589</guid>
      <dc:creator>DaveStar</dc:creator>
      <dc:date>2019-09-26T05:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: remerging summary statistics with raw data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591854#M169634</link>
      <description>&lt;P&gt;The answer you got from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp; is probably the solution I would suggest for this exact query. But there may be other situations where you want to use a subquery, you can do it like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
 create table tbl as
    select  detail.*,sum.*
    from sashelp.shoes as  detail,
	               (select sum(sales) as total_sales,
		               count(* ) as Total_count 
               from sashelp.shoes) as sum

  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that as your queries get larger and more complicated, it makes thing a lot easier in the long run if you use more describing aliases than "a" and "b", in this case "detail" and "sum" seem better. I know, everybody (except yours truly) use short and cryptic aliases, but they really should not!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 13:03:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591854#M169634</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-09-26T13:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: remerging summary statistics with raw data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591946#M169671</link>
      <description>&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 18:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remerging-summary-statistics-with-raw-data/m-p/591946#M169671</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-09-26T18:27:30Z</dc:date>
    </item>
  </channel>
</rss>

