<?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: i have 80 data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663416#M198035</link>
    <description>&lt;P&gt;Please supply example data in usable form (data step with datalines), and what you want to get out of it. &lt;STRONG&gt;DO NOT SKIP THIS&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;From your description, I cannot make up what your data looks like; use SAS terminology in desctiptions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;dataset: a table consisting of rows&lt;/LI&gt;
&lt;LI&gt;observation: a single row within the table&lt;/LI&gt;
&lt;LI&gt;variable: a single column within a row&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Fri, 19 Jun 2020 09:51:34 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-06-19T09:51:34Z</dc:date>
    <item>
      <title>i have 80 data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663415#M198034</link>
      <description>&lt;P&gt;I have 80 data consist of 12 buyers. I&amp;nbsp;would like to analyze how much every buyer has spent. How can I calculate the total amount spent by every buyer?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 09:44:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663415#M198034</guid>
      <dc:creator>IdlanHnf</dc:creator>
      <dc:date>2020-06-19T09:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: i have 80 data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663416#M198035</link>
      <description>&lt;P&gt;Please supply example data in usable form (data step with datalines), and what you want to get out of it. &lt;STRONG&gt;DO NOT SKIP THIS&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;From your description, I cannot make up what your data looks like; use SAS terminology in desctiptions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;dataset: a table consisting of rows&lt;/LI&gt;
&lt;LI&gt;observation: a single row within the table&lt;/LI&gt;
&lt;LI&gt;variable: a single column within a row&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 19 Jun 2020 09:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663416#M198035</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-19T09:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: i have 80 data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663419#M198036</link>
      <description>&lt;P&gt;here is my data. OrderID, Buyer, Price, Item, Unit, Courier are my variables. From this data, I have 12 buyers, I want to calculate the total amount spent by every buyer.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 10:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663419#M198036</guid>
      <dc:creator>IdlanHnf</dc:creator>
      <dc:date>2020-06-19T10:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: i have 80 data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663423#M198037</link>
      <description>&lt;P&gt;&lt;STRONG&gt;SQL&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Compute each buyer's spending total, presuming the transaction amount would have to be computed as &lt;EM&gt;transaction_amount = price * unit&lt;/EM&gt;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table buyer_totals as
  select buyer, sum(price*unit) as spend_total&lt;BR /&gt;  from myData&lt;BR /&gt;  group by buyer&lt;BR /&gt;  ;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jun 2020 10:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663423#M198037</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-06-19T10:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: i have 80 data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663433#M198040</link>
      <description>&lt;P&gt;thanks for your help. it's working so well. by any chance, do you know how to sort it ascending or descending? I want to sort it so that I will started with the highest revenue. And if you don't mind, is it possible if I want to try combine this two SQL run it?&lt;/P&gt;&lt;PRE&gt;PROC SQL;&lt;BR /&gt;	CREATE TABLE buyerspent AS&lt;BR /&gt;	SELECT Buyer, sum('Price (RM)'n*unit) AS 'Total Spend (RM)'n&lt;BR /&gt;	FROM Payment&lt;BR /&gt;	GROUP BY Buyer;&lt;BR /&gt;RUN;&lt;BR /&gt;PROC PRINT DATA=buyerspent;&lt;BR /&gt;	TITLE 'Monarch Online Shop';&lt;BR /&gt;	FOOTNOTE 'STAY AT HOME AND STAY SAFE';&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;	CREATE TABLE revenue AS&lt;BR /&gt;	SELECT 'Item ID'n, sum('Price (RM)'n*unit) AS 'Total Revenue (RM)'n&lt;BR /&gt;	FROM Payment&lt;BR /&gt;	GROUP BY 'Item ID'n;&lt;BR /&gt;RUN;&lt;BR /&gt;PROC PRINT DATA=revenue;&lt;BR /&gt;	TITLE 'Monarch Online Shop';&lt;BR /&gt;	FOOTNOTE 'STAY AT HOME AND STAY SAFE';&lt;BR /&gt;RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 11:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663433#M198040</guid>
      <dc:creator>IdlanHnf</dc:creator>
      <dc:date>2020-06-19T11:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: i have 80 data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663437#M198041</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/334109"&gt;@IdlanHnf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an alternative to PORC SQL, you can also use a simple PROC MEANS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=myData nway noprint;
	class buyer;
	var price;
	weight unit;
	output out=buyer_totals (drop=_:) sum= / autoname; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need a report -&amp;gt; remove the NOPRINT option&lt;/P&gt;
&lt;P&gt;If you need a table -&amp;gt; keep the OUTPUT OUT= statement.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 11:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663437#M198041</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-19T11:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: i have 80 data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663471#M198059</link>
      <description>&lt;P&gt;Use the SQL clause ORDER BY.&lt;/P&gt;
&lt;PRE&gt;PROC SQL;
	CREATE TABLE buyerspent AS
	SELECT Buyer, sum('Price (RM)'n*unit) AS 'Total Spend (RM)'n
	FROM Payment
	GROUP BY Buyer
        ORDER BY  'Total Spend (RM)'n descending ;
RUN;&lt;/PRE&gt;
&lt;P&gt;SAS is different than other systems.&amp;nbsp; Each variable can have a LABEL associated with it, and that label is shown during output.&amp;nbsp; Meanwhile, the variable can be specified using it's simpler&amp;nbsp;&lt;EM&gt;name.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; sum('Price (RM)'n*unit) AS total &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;label='Total Spend (RM)'&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;                            ^^^^^       ^^^^^^^^^^^^^^^^^^&lt;BR /&gt;                            name        label&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;To report on multiple variables it is often better to use a procedure such as REPORT or TABULATE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data forPresentation;
  set myData;
  amount = price * unit;
run;

proc tabulate data=forPresentation;
  class buyer item;
  var amount;&lt;BR /&gt;  table (buyer item), amount;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 13:10:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-80-data/m-p/663471#M198059</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-06-19T13:10:04Z</dc:date>
    </item>
  </channel>
</rss>

