<?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: Grouping In PROC PRINT step in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47422#M12730</link>
    <description>Hi. Cynthia. I am boy ,thirty years old.hehe.</description>
    <pubDate>Mon, 12 Jul 2010 15:24:55 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2010-07-12T15:24:55Z</dc:date>
    <item>
      <title>Grouping In PROC PRINT step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47418#M12726</link>
      <description>Hello People. I'm learner in SAS.&lt;BR /&gt;
&lt;BR /&gt;
I have a simple query in access:&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;&lt;B&gt;SELECT Tbl.Location, Tbl.Jobcode, Count(Tbl.EmpId), Sum(Tbl.Salary)&lt;BR /&gt;
FROM Tbl&lt;BR /&gt;
GROUP BY Tbl.Location, Tbl.Jobcode;&lt;/B&gt;&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
I need to display the same results in SAS. The dataset is created.&lt;BR /&gt;
&lt;BR /&gt;
The code i'm trying to write is as follows: &lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;PROC SORT DATA = msdq.crew OUT=work.Tbl;&lt;BR /&gt;
BY Location Jobcode;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC PRINT DATA = Tbl; &lt;BR /&gt;
ID Location Jobcode; &lt;BR /&gt;
BY Location Jobcode; &lt;BR /&gt;
VAR Salary; &lt;BR /&gt;
SUM Salary; &lt;BR /&gt;
RUN;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
I need to write Count(EmpId) and Sum(Salary)&lt;BR /&gt;
&lt;BR /&gt;
And also the above code does not group the two variables; it creates a Sub-total and a grand total.&lt;BR /&gt;
&lt;BR /&gt;
How to group. Help me out plz ?</description>
      <pubDate>Mon, 12 Jul 2010 09:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47418#M12726</guid>
      <dc:creator>Jazz_SAS</dc:creator>
      <dc:date>2010-07-12T09:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping In PROC PRINT step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47419#M12727</link>
      <description>Why don't you just use this already tested SQL code in SAS?&lt;BR /&gt;
&lt;BR /&gt;
Proc sql;&lt;BR /&gt;
SELECT Tbl.Location, Tbl.Jobcode, Count(Tbl.EmpId), Sum(Tbl.Salary)&lt;BR /&gt;
FROM Tbl&lt;BR /&gt;
GROUP BY Tbl.Location, Tbl.Jobcode;&lt;BR /&gt;
quit;</description>
      <pubDate>Mon, 12 Jul 2010 09:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47419#M12727</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-07-12T09:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping In PROC PRINT step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47420#M12728</link>
      <description>proc report or proc tabulate would be a better choice.&lt;BR /&gt;
and Cynthia@sas.com can do it better.hehe.&lt;BR /&gt;
This is just an example.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc tabulate data=sashelp.class;&lt;BR /&gt;
 class sex name;&lt;BR /&gt;
 var weight height;&lt;BR /&gt;
 table sex*name,weight*n height*sum;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 12 Jul 2010 11:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47420#M12728</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-07-12T11:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping In PROC PRINT step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47421#M12729</link>
      <description>Hi:&lt;BR /&gt;
  Ksharp has posted one possible solution. Another solution (if you want a "grouped" report (such as without name), would be to take her TABULATE code and remove the "*name" from the TABLE statement.&lt;BR /&gt;
 &lt;BR /&gt;
  Otherwise, you can also achieve a grouped or summary report with PROC REPORT, as well, consider the program below. In this program, the variables SEX and AGE are group variables and so the "detailed" observations will collapse into groups of unique ages within each sex value. Then the Weight variable is used to get the N statistic to count the observations in each SEX/AGE group and the HEIGHT variable is used to get the SUM of HEIGHTS (not very meaningful, but it is only meant to show the use of the SUM statistic).&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
 [pre]&lt;BR /&gt;
proc report data=sashelp.class nowd;&lt;BR /&gt;
  column sex age weight height;&lt;BR /&gt;
  define sex / group;&lt;BR /&gt;
  define age / group;&lt;BR /&gt;
  define height / sum;&lt;BR /&gt;
  define weight / n 'Count';&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 12 Jul 2010 14:38:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47421#M12729</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-07-12T14:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping In PROC PRINT step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47422#M12730</link>
      <description>Hi. Cynthia. I am boy ,thirty years old.hehe.</description>
      <pubDate>Mon, 12 Jul 2010 15:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47422#M12730</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-07-12T15:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping In PROC PRINT step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47423#M12731</link>
      <description>Sorry for the misunderstanding.</description>
      <pubDate>Mon, 12 Jul 2010 16:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Grouping-In-PROC-PRINT-step/m-p/47423#M12731</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-07-12T16:00:45Z</dc:date>
    </item>
  </channel>
</rss>

