<?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: Need Grouping with all data fields in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482924#M125162</link>
    <description>&lt;P&gt;please check the smaller HAVE and WANT data.&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jul 2018 19:38:29 GMT</pubDate>
    <dc:creator>Rahul_SAS</dc:creator>
    <dc:date>2018-07-31T19:38:29Z</dc:date>
    <item>
      <title>Need Grouping with all data fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482895#M125152</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to group the given data by pcode, empname, mname, team, date in the final data "STAG3 " but not getting the correct result. while, if i don't include date, it gives correct value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please look into the below code and correct me if i am making any mistake.&lt;/P&gt;
&lt;P&gt;Sample data is attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need Grouping by pcode, empname, mname, team, date data fields for CasePercentage .&lt;/P&gt;
&lt;P&gt;Is there any efficient way to do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql ;&lt;BR /&gt;create table stag1 as &lt;BR /&gt;select &lt;BR /&gt;distinct pcode, empname, mname, team, caseid, type, ser, status, date&lt;BR /&gt;from report_data;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table stag2 as&lt;BR /&gt;select stag1.*,&lt;BR /&gt;case when status In ('QCCOMP') AND caseid NOT IN ('') THEN '1' else '0' end as Case_ID_for_QCCOMP,&lt;BR /&gt;case when status In ('QCCOMPERR') AND caseid NOT IN ('') THEN '1' else '0' end as Case_ID_for_QCCOMPERR,&lt;BR /&gt;case when status In ('QCCOMP','QCCOMPERR') AND caseid NOT IN ('') THEN '1' else '0' end as Total_Case_IDs&lt;BR /&gt;from stag1; &lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table STAG3 as&lt;BR /&gt;select distinct pcode, empname, mname, team,&lt;BR /&gt;(COMP/(COMP+COMPERR))*100 AS CasePercentage &lt;BR /&gt;from &lt;BR /&gt;(select &lt;BR /&gt;distinct pcode, empname, mname, team,&lt;BR /&gt;sum(input(Case_ID_for_QCCOMP,BEST12.)) as COMP,&lt;BR /&gt;sum(input(Case_ID_for_QCCOMPERR,BEST12.)) as COMPERR&lt;BR /&gt;FROM stag2&lt;BR /&gt;group by &lt;BR /&gt;pcode, empname, mname, team&lt;/P&gt;
&lt;P&gt;) as test;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 17:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482895#M125152</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2018-07-31T17:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need Grouping with all data fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482900#M125153</link>
      <description>&lt;P&gt;Can you plz&amp;nbsp; include&amp;nbsp; sample (preferably small samples of your input and your expected(desired) output&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 18:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482900#M125153</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-31T18:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need Grouping with all data fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482910#M125160</link>
      <description>&lt;P&gt;From the spreadsheet, which is &lt;STRONG&gt;not&lt;/STRONG&gt; a SAS data set and may differ notably from your SAS data set, the "date" variable is a date time.&amp;nbsp; If your data set has that variable continuing to be a datetime then perhaps you want to use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select &lt;BR /&gt;distinct pcode, empname, mname, team, caseid, type, ser, status, datepart(date) as date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assign a preferred format to this date variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your spreadsheet had times down to fractions of a second that would be a very likely reason that the grouping wasn't as you desired as each second or fraction would be a different group&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 18:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482910#M125160</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-31T18:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need Grouping with all data fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482914#M125161</link>
      <description>&lt;P&gt;It seems like it should work if your subquery was:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select 
    pcode, 
    empname, 
    mname, 
    team, 
    date,
    sum(input(Case_ID_for_QCCOMP,BEST12.)) as COMP,
    sum(input(Case_ID_for_QCCOMPERR,BEST12.)) as COMPERR
FROM stag2
group by pcode, empname, mname, team, date&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jul 2018 19:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482914#M125161</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-31T19:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need Grouping with all data fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482924#M125162</link>
      <description>&lt;P&gt;please check the smaller HAVE and WANT data.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 19:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482924#M125162</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2018-07-31T19:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need Grouping with all data fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482937#M125168</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2837"&gt;@Rahul_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;please check the smaller HAVE and WANT data.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 20:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Grouping-with-all-data-fields/m-p/482937#M125168</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-31T20:54:01Z</dc:date>
    </item>
  </channel>
</rss>

