<?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 Base query in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71751#M8213</link>
    <description>I have this data set.&lt;BR /&gt;
&lt;BR /&gt;
Group        Student        Point&lt;BR /&gt;
A0001        Thomas       100&lt;BR /&gt;
A0001          Sue             90&lt;BR /&gt;
A0001         Chan           81&lt;BR /&gt;
A0002         Ray              66&lt;BR /&gt;
A0002         Jacky            67&lt;BR /&gt;
A0003        Aaron            69&lt;BR /&gt;
.....&lt;BR /&gt;
A1500     Gigi              78&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
In the above example, I would like to create data set for individual group...I could have 1500 groups.&lt;BR /&gt;
&lt;BR /&gt;
Dataset A0001 should have student from A0001 only.&lt;BR /&gt;
&lt;BR /&gt;
Can anyone help?</description>
    <pubDate>Sat, 27 Mar 2010 11:34:44 GMT</pubDate>
    <dc:creator>toffee</dc:creator>
    <dc:date>2010-03-27T11:34:44Z</dc:date>
    <item>
      <title>Base query</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71751#M8213</link>
      <description>I have this data set.&lt;BR /&gt;
&lt;BR /&gt;
Group        Student        Point&lt;BR /&gt;
A0001        Thomas       100&lt;BR /&gt;
A0001          Sue             90&lt;BR /&gt;
A0001         Chan           81&lt;BR /&gt;
A0002         Ray              66&lt;BR /&gt;
A0002         Jacky            67&lt;BR /&gt;
A0003        Aaron            69&lt;BR /&gt;
.....&lt;BR /&gt;
A1500     Gigi              78&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
In the above example, I would like to create data set for individual group...I could have 1500 groups.&lt;BR /&gt;
&lt;BR /&gt;
Dataset A0001 should have student from A0001 only.&lt;BR /&gt;
&lt;BR /&gt;
Can anyone help?</description>
      <pubDate>Sat, 27 Mar 2010 11:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71751#M8213</guid>
      <dc:creator>toffee</dc:creator>
      <dc:date>2010-03-27T11:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Base query</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71752#M8214</link>
      <description>Hi:&lt;BR /&gt;
  Since you are posting this in the ODS and Base SAS Reporting forum -- there is an automated way to create output REPORTS (different from output DATASETS) using ODS and the NEWFILE= option. For example, if you ran a PROC PRINT using NEWFILE= BYGROUP:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  ods html file='bygrp1.html' newfile=bygroup style=sasweb;&lt;BR /&gt;
        proc print data=student;&lt;BR /&gt;
             by group;&lt;BR /&gt;
       run;&lt;BR /&gt;
  ods html close;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Then if you had 10 groups, the HTML reports for each group would be nameed BYGRP1.HTML thru BYGRP10.HTML. However, these would be REPORT files, not SAS datasets.&lt;BR /&gt;
&lt;BR /&gt;
In order to create DATASETS, you will have to use some kind of repetitive logic, either in a DATA step program, PROC SQL or even a PROC SORT step (a DATA step approach and a PROC SORT approach are shown below):&lt;BR /&gt;
 [pre]&lt;BR /&gt;
**** DATA step example;&lt;BR /&gt;
   data work.A0001 work.A0002 work.A0003;&lt;BR /&gt;
       set student;&lt;BR /&gt;
      if group = 'A0001' then output work.A0001;&lt;BR /&gt;
      else if group = 'A0002' then output work.A0002;&lt;BR /&gt;
      else if group = 'A0003' then output work.A0003;&lt;BR /&gt;
  run;&lt;BR /&gt;
&lt;BR /&gt;
         &lt;BR /&gt;
*** PROC SORT example;&lt;BR /&gt;
&lt;BR /&gt;
  proc sort data=student out=work.A0001;&lt;BR /&gt;
      by group student;&lt;BR /&gt;
      where group eq 'A0001';&lt;BR /&gt;
  run;&lt;BR /&gt;
                                           &lt;BR /&gt;
  proc sort data=student out=work.A0002;&lt;BR /&gt;
      by group student;&lt;BR /&gt;
      where group eq 'A0002';&lt;BR /&gt;
  run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                 &lt;BR /&gt;
To create a program where you did not need to know the names or number of GROUP values ahead of time, you would need to move into the world of SAS Macro processing.&lt;BR /&gt;
                      &lt;BR /&gt;
These papers are a good introduction into the SAS Macro facility and should give you some ideas about how to automate the process of creating multiple SAS datasets from your one big file. &lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi28/056-28.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi28/056-28.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/proceedings09/151-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/151-2009.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/130-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/130-30.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/proceedings09/200-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/200-2009.pdf&lt;/A&gt;&lt;BR /&gt;
  &lt;BR /&gt;
cynthia</description>
      <pubDate>Sat, 27 Mar 2010 15:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71752#M8214</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-03-27T15:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Base query</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71753#M8215</link>
      <description>I am interested on this part, I was doing exactly as in the example, but what if i have hundreds of groups? Is that any better way?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
**** DATA step example;&lt;BR /&gt;
   data work.A0001 work.A0002 work.A0003;&lt;BR /&gt;
       set student;&lt;BR /&gt;
      if group = 'A0001' then output work.A0001;&lt;BR /&gt;
      else if group = 'A0002' then output work.A0002;&lt;BR /&gt;
      else if group = 'A0003' then output work.A0003;&lt;BR /&gt;
  run;</description>
      <pubDate>Sat, 27 Mar 2010 18:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71753#M8215</guid>
      <dc:creator>toffee</dc:creator>
      <dc:date>2010-03-27T18:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Base query</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71754#M8216</link>
      <description>Yes, using SAS MACRO language, as Cynthia replied.  You will end up with a general-purpose SAS DATA step that reads your SAS file (create an index for performance) and either use a WHERE statement or generate your list of unique group values and use the macro code to generate your DATA statement and your IF/THEN OUTPUT;  code, in a similar form as you have demonstrated in your reply.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sat, 27 Mar 2010 18:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71754#M8216</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-27T18:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Base query</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71755#M8217</link>
      <description>Hi:&lt;BR /&gt;
  As I said in my previous post:&lt;BR /&gt;
&lt;B&gt;&lt;BR /&gt;
To create a program where you did not need to know the names or number of GROUP values ahead of time, you would need to move into the world of SAS Macro processing.&lt;BR /&gt;
&lt;/B&gt;&lt;BR /&gt;
 &lt;BR /&gt;
The links to papers at the end of the post should give you a start at understanding SAS Macro processing.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Sat, 27 Mar 2010 18:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Base-query/m-p/71755#M8217</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-03-27T18:27:50Z</dc:date>
    </item>
  </channel>
</rss>

