<?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: Subsetting Dataset using Proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-using-Proc-sql/m-p/388095#M93089</link>
    <description>&lt;P&gt;&lt;SPAN&gt;It is not possible to produce multiple tables or views in a single sql&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;query.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best way could be :&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;BR /&gt;create table lt_15k as select * from sas1.cars where price le 15 ;&lt;BR /&gt;create table lt_20k as select * from sas1.cars where price between 15 and 20 ; &lt;BR /&gt;create table lt_30k as select * from sas1.cars where price between 20 and 30 ; &lt;BR /&gt;create table lt_40k as select * from sas1.cars where price between 30 and 40 ; &lt;BR /&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Aug 2017 10:44:40 GMT</pubDate>
    <dc:creator>Thamaraikannan</dc:creator>
    <dc:date>2017-08-15T10:44:40Z</dc:date>
    <item>
      <title>Subsetting Dataset using Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-using-Proc-sql/m-p/388089#M93088</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to subset dataset based on the ranges in the dataset. I have done subsetting using Data step as :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA lt_15k lt_20k lt_30k lt_40k gt_40k;&lt;BR /&gt;set sas1.cars;&lt;BR /&gt;if price le 15 then Output lt_15k;&lt;BR /&gt;if (15&amp;lt;price&amp;lt;=20) then Output lt_20k;&lt;BR /&gt;if (20&amp;lt;price&amp;lt;=30) then Output lt_30k;&lt;BR /&gt;if (30&amp;lt;price&amp;lt;=40) then Output lt_40k;&lt;BR /&gt;if (price&amp;gt;40) then output gt_40k;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want same results by using Proc SQL command. Is possible to create multiple dataset using proc sql.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 10:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-using-Proc-sql/m-p/388089#M93088</guid>
      <dc:creator>Harmandeep</dc:creator>
      <dc:date>2017-08-15T10:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Dataset using Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-using-Proc-sql/m-p/388095#M93089</link>
      <description>&lt;P&gt;&lt;SPAN&gt;It is not possible to produce multiple tables or views in a single sql&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;query.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best way could be :&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;BR /&gt;create table lt_15k as select * from sas1.cars where price le 15 ;&lt;BR /&gt;create table lt_20k as select * from sas1.cars where price between 15 and 20 ; &lt;BR /&gt;create table lt_30k as select * from sas1.cars where price between 20 and 30 ; &lt;BR /&gt;create table lt_40k as select * from sas1.cars where price between 30 and 40 ; &lt;BR /&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 10:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-using-Proc-sql/m-p/388095#M93089</guid>
      <dc:creator>Thamaraikannan</dc:creator>
      <dc:date>2017-08-15T10:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Dataset using Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-using-Proc-sql/m-p/388102#M93092</link>
      <description>&lt;P&gt;You cannot in SQL. &amp;nbsp;I would however question the benefitof splitting the data in the first place. &amp;nbsp;First off you are multiplying the size of the size as you have each of the header blocks in addition, so this method takes more space. &amp;nbsp;It is also harder to program with as you need to know the datasets, and program for each of them. &amp;nbsp;A simpler methodology is to apply the grouping in the data, and then use that grouping. &amp;nbsp;Say you want to print each of those groups to a diffrent page:&lt;/P&gt;
&lt;PRE&gt;DATA lt_15k lt_20k lt_30k lt_40k gt_40k;
set sas1.cars;
if price le 15 then Output lt_15k;
if (15&amp;lt;price&amp;lt;=20) then Output lt_20k;
if (20&amp;lt;price&amp;lt;=30) then Output lt_30k;
if (30&amp;lt;price&amp;lt;=40) then Output lt_40k;
if (price&amp;gt;40) then output gt_40k;
run;&lt;BR /&gt;title "Group1 ";
Proc print data=lt_15k_20k;
run;&lt;BR /&gt;title "Group2";
proc print data=...
&lt;/PRE&gt;
&lt;P&gt;Or, and this should look simpler:&lt;/P&gt;
&lt;PRE&gt;data want;
  set sas1.cars;
  if price le 15 then group="lt_15k";
  if (15&amp;lt;price&amp;lt;=20) then group="t_20k";
  if (20&amp;lt;price&amp;lt;=30) then group="lt_30k";
  if (30&amp;lt;price&amp;lt;=40) then group="lt_40k";
  if (price&amp;gt;40) then group="gt_40k";
run;

proc print data=want;
  by group;
  title "Group: #byval1";
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Aug 2017 11:22:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-using-Proc-sql/m-p/388102#M93092</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-15T11:22:08Z</dc:date>
    </item>
  </channel>
</rss>

