<?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: Using Formats to Group values in the Filter &amp; Query Task in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-Formats-to-Group-values-in-the-Filter-Query-Task/m-p/76331#M7597</link>
    <description>My suggestion would be exactly what you mention: create a new column using a PUT function and your user-defined format. IMO, I don't think you're missing anything simpler.</description>
    <pubDate>Wed, 21 Oct 2009 17:54:59 GMT</pubDate>
    <dc:creator>RichardH_sas</dc:creator>
    <dc:date>2009-10-21T17:54:59Z</dc:date>
    <item>
      <title>Using Formats to Group values in the Filter &amp; Query Task</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-Formats-to-Group-values-in-the-Filter-Query-Task/m-p/76330#M7596</link>
      <description>I am using SAS Enterprise Guide 4.1 (4.1.0.471) and want to be able to use the Filter &amp;amp; Query task to summarise my data using an existing user-defined format to group my values.&lt;BR /&gt;
&lt;BR /&gt;
As an example, my demo data looks like this:&lt;BR /&gt;
&lt;BR /&gt;
Data Transactions;&lt;BR /&gt;
 Input 	Cust_No&lt;BR /&gt;
   		Trans_Code&lt;BR /&gt;
  		;&lt;BR /&gt;
Datalines;&lt;BR /&gt;
555 1&lt;BR /&gt;
555 1&lt;BR /&gt;
330 2&lt;BR /&gt;
630 2&lt;BR /&gt;
777 2&lt;BR /&gt;
805 3&lt;BR /&gt;
658 4&lt;BR /&gt;
;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
My demo format looks like this:&lt;BR /&gt;
&lt;BR /&gt;
Proc Format Library=WORK;&lt;BR /&gt;
 Value Trans_Code 1,2         = "Purchases"&lt;BR /&gt;
      		  3,4,5,6,7,9 = "Cash Advances"&lt;BR /&gt;
                  Other       = "Unknown"&lt;BR /&gt;
                  ;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
when hand-coding (ie writing SAS code myself) I can use either of the following techniques:&lt;BR /&gt;
&lt;BR /&gt;
1) Use Proc Summary with a Format statement to group by the Trans_Code variable after being passed through the format Trans_Code.&lt;BR /&gt;
&lt;BR /&gt;
Proc Summary Data=Transactions NWAY missing;&lt;BR /&gt;
 Class Trans_Code;&lt;BR /&gt;
 Format Trans_Code Trans_Code.;&lt;BR /&gt;
Output Out=SummaryA(Drop=_TYPE_ Rename=(_FREQ_=NumberOfRows))&lt;BR /&gt;
;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
2) Use Proc SQL with a Put function to group Trans_Code values by the format, Trans_Code.&lt;BR /&gt;
&lt;BR /&gt;
Proc SQL;&lt;BR /&gt;
 Create Table SummaryB As&lt;BR /&gt;
 Select Put(Trans_Code, Trans_Code.) As GroupTranscode,&lt;BR /&gt;
        Count(*) As NumberOfRows&lt;BR /&gt;
 From   Transactions&lt;BR /&gt;
 Group  By Calculated GroupTranscode &lt;BR /&gt;
 ;&lt;BR /&gt;
Quit;&lt;BR /&gt;
&lt;BR /&gt;
However, I need to be able to do this same grouping from the Filter &amp;amp; Query task , ie without writing code. I realise that the Recode A Column feature of the Calculated Column option can produce the same results as I require, but having to hand-build the rules for re-coding a column each time is not practical. In my real data, there are many hundreds of discreet Trans_Code values and the SAS format that we have built reduces these down to about 50 groups.&lt;BR /&gt;
&lt;BR /&gt;
Does anyone know how we can use the Filter &amp;amp; Query Task to do the above. The only way I can think of doing it is to build a Calculated Column with the Expression Builder and build an expression as:&lt;BR /&gt;
&lt;BR /&gt;
Put(Trans_Code, Trans_Code.)&lt;BR /&gt;
&lt;BR /&gt;
I wonder if I am missing something a bit more obvious that is buried in the Filter &amp;amp; Query Task somwhere.&lt;BR /&gt;
&lt;BR /&gt;
Any thoughts, anyone ?&lt;BR /&gt;
&lt;BR /&gt;
Many thanks,&lt;BR /&gt;
&lt;BR /&gt;
Down-under-Dave&lt;BR /&gt;
Wellington&lt;BR /&gt;
New Zealand</description>
      <pubDate>Wed, 21 Oct 2009 09:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-Formats-to-Group-values-in-the-Filter-Query-Task/m-p/76330#M7596</guid>
      <dc:creator>DaveShea</dc:creator>
      <dc:date>2009-10-21T09:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using Formats to Group values in the Filter &amp; Query Task</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-Formats-to-Group-values-in-the-Filter-Query-Task/m-p/76331#M7597</link>
      <description>My suggestion would be exactly what you mention: create a new column using a PUT function and your user-defined format. IMO, I don't think you're missing anything simpler.</description>
      <pubDate>Wed, 21 Oct 2009 17:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-Formats-to-Group-values-in-the-Filter-Query-Task/m-p/76331#M7597</guid>
      <dc:creator>RichardH_sas</dc:creator>
      <dc:date>2009-10-21T17:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using Formats to Group values in the Filter &amp; Query Task</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-Formats-to-Group-values-in-the-Filter-Query-Task/m-p/76332#M7598</link>
      <description>Hi Dave&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
using your sample data to create Transactions and the trans_code format, I then used the filter query task and added the two columns and grouped by Cust_no.&lt;BR /&gt;
&lt;BR /&gt;
I just changed the format of Cust_no to trans_code and came up with the same answer without using put statements.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
 CREATE TABLE WORK.Query_for_SUMMARYA AS SELECT SUMMARYA.Trans_Code FORMAT=TRANS_CODE.,&lt;BR /&gt;
	 (SUM(SUMMARYA.NumberOfRows)) AS SUM_OF_NumberOfRows &lt;BR /&gt;
 FROM WORK.SUMMARYA AS SUMMARYA&lt;BR /&gt;
 GROUP BY SUMMARYA.Trans_Code;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
&lt;BR /&gt;
Derek

Message was edited by: Derek Adams</description>
      <pubDate>Wed, 21 Oct 2009 18:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-Formats-to-Group-values-in-the-Filter-Query-Task/m-p/76332#M7598</guid>
      <dc:creator>DerekAdams</dc:creator>
      <dc:date>2009-10-21T18:30:56Z</dc:date>
    </item>
  </channel>
</rss>

