<?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: agroup and summary (using sas code not proc sql) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329270#M73641</link>
    <description>&lt;P&gt;That's the default Proc freq&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;table state*store/out=want;&lt;/P&gt;
&lt;P&gt;weight sales;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Feb 2017 02:25:52 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-02-02T02:25:52Z</dc:date>
    <item>
      <title>agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329264#M73636</link>
      <description>&lt;P&gt;How can I agroup in a summary if i have this obs:&lt;/P&gt;&lt;P&gt;STATE STORE SALES&lt;BR /&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;BR /&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;AK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;BR /&gt;AK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;BR /&gt;AZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;AZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;AZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; E&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;BR /&gt;AZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; E&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;BR /&gt;AR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;AR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result I want is:&lt;/P&gt;&lt;P&gt;STATE STORE SALES&lt;BR /&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;BR /&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;AK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;BR /&gt;AZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;BR /&gt;AZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; E&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;BR /&gt;AR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;(using sas code not proc sql)&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 01:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329264#M73636</guid>
      <dc:creator>Angel_Saenz</dc:creator>
      <dc:date>2017-02-02T01:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329266#M73637</link>
      <description>&lt;P&gt;Try an approach like this. It's not tested, but you should be able to make it work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort;
    by state store;
run;

data want;
    retain sum;
    set have;
    by state store;
    if first.store then sum = sales;
    else sum = sum + sales;
    if last.store then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Feb 2017 01:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329266#M73637</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-02-02T01:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329270#M73641</link>
      <description>&lt;P&gt;That's the default Proc freq&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;table state*store/out=want;&lt;/P&gt;
&lt;P&gt;weight sales;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 02:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329270#M73641</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-02T02:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329312#M73656</link>
      <description>&lt;P&gt;And a third common approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=have nway;&lt;/P&gt;
&lt;P&gt;class state store;&lt;/P&gt;
&lt;P&gt;var sales;&lt;/P&gt;
&lt;P&gt;output out=want (keep=state store sales) sum=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 07:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329312#M73656</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-02T07:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329494#M73723</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Please&lt;/STRONG&gt; define what you may mean by "SAS Code" as Proc SQL &lt;STRONG&gt;is&lt;/STRONG&gt; SAS code. You obviously have something in mind but you really should clarify.&lt;/P&gt;
&lt;P&gt;If your process cannot use Proc SQL please explain why. There are some things that Proc SQL is designed to do such as a many-to-many merge that could take a lot of other coding to accomplish. There are cases where this type of request is similar to "I need to excavate for a building foundation but cannot use the backhoe that is sitting on the property but must use a table spoon."&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 16:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329494#M73723</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-02T16:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329627#M73780</link>
      <description>&lt;P&gt;Hello ballardw you always help me with my questions, I prefer use sas code not proc sql because some process I know how do it with proc sql, but I want to learn how do it with code sas pure&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 22:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329627#M73780</guid>
      <dc:creator>Angel_Saenz</dc:creator>
      <dc:date>2017-02-02T22:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329632#M73782</link>
      <description>&lt;P&gt;PROC SQL is 'pure sas', whatever that means.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think what you're trying to say, is you'd like to learn using data step and procs such as summary/univariate rather than proc sql. Saying that PROC SQL isn't 'SAS' would be incorrect and it's just as useful and in fact can be the easiest way to accomplish certain tasks. Personally, I find all joins are easier for me to manage via SQL, especially since many to many merges aren't handled as expected in a data step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think your questions been answered, so please mark it solved with the correct solution selected &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 22:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329632#M73782</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-02T22:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329636#M73785</link>
      <description>&lt;P&gt;I agree with you Reeza you too always help me with my questions, Im just starting to use sas Im newbie sorry if my questions are too basics other problem is that I dont know english very well my lenguage is spanish and is difficult for me ask and explain in english my questions well thank you for your patience, in other way for agroup I have 2 solutions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 proc freq&lt;/P&gt;&lt;P&gt;2 proc summary&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what do you thing is better?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 23:04:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329636#M73785</guid>
      <dc:creator>Angel_Saenz</dc:creator>
      <dc:date>2017-02-02T23:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329638#M73787</link>
      <description>&lt;P&gt;Proc Summary or Proc Tabulate as you have more control of the output format and style.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 23:12:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329638#M73787</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-02T23:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329642#M73790</link>
      <description>&lt;P&gt;There's nothing to apologize for as well, ask your questions regardless of how basic. Unfortunately in programming terminology can be important so it's good to identify specific key words that don't make sense, ie pure sas. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 23:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329642#M73790</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-02T23:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329841#M73845</link>
      <description>&lt;P&gt;Thanks Reeza for example cold you please explain how do this proc sql to proc summary and proc tabulate?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; STATE, STORE, PRODUCT, Count(NSALES) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SALES&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; BIGSHOP&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;GROUP&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;BY&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;FONT face="Courier New"&gt;STATE, STORE, PRODUCT&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I think if you help me to convert this &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;PROC&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL to proc summary and proc tabulate everything is clear for me and the future.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2017 17:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329841#M73845</guid>
      <dc:creator>Angel_Saenz</dc:creator>
      <dc:date>2017-02-03T17:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: agroup and summary (using sas code not proc sql)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329889#M73867</link>
      <description>&lt;P&gt;You should try these yourself still. Also, work through a paper perhaps, this is a good one here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi29/240-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/240-29.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's some sample code based on SASHELP.SHOES data set since I find it hard to write code without a data set to check the results. The concept is the same, N is for count, Sum is the sum and mean is average. Check the documentation for the other statistics you can calculate.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc means is typically used to calculate stats and proc tabulate is more for displaying results in a specified format, ie developing reports.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.shoes nway;
class region product subsidiary;
output out=want n=Count sum(sales)=Total_Sales;
run;

proc print data=want (drop =_type_ _freq_ obs=10);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2017 20:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/agroup-and-summary-using-sas-code-not-proc-sql/m-p/329889#M73867</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-03T20:34:52Z</dc:date>
    </item>
  </channel>
</rss>

