<?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: proc sql to create two datasets from one dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413641#M101268</link>
    <description>&lt;P&gt;Sorry for late response. I would try recommended code. Thanks all for helping me out here.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Nov 2017 13:14:54 GMT</pubDate>
    <dc:creator>buddha_d</dc:creator>
    <dc:date>2017-11-15T13:14:54Z</dc:date>
    <item>
      <title>proc sql to create two datasets from one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413562#M101244</link>
      <description>&lt;P&gt;guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I am trying to create two datasets from one huge dataset. One I need to create last two weeks data and sum it and second data is to sum it for the entire month. I need to see the difference for the two weeks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using following code to create two datasets. I was wondering if I can create one proc sql to create two datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table two_weeks as&amp;nbsp;&lt;/P&gt;&lt;P&gt;select a.*, sum (rec_amount) as two_sum&amp;nbsp;&lt;/P&gt;&lt;P&gt;from walgreen.history a&lt;/P&gt;&lt;P&gt;where date &amp;gt;= today()-15; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table month as&amp;nbsp;&lt;/P&gt;&lt;P&gt;select a.*, sum (rec_amount) as month_sum, (calculated month_sum-b.two_sum ) as balance&amp;nbsp;&lt;/P&gt;&lt;P&gt;from walgreen.history a, two_weeks b&amp;nbsp;&lt;/P&gt;&lt;P&gt;where date &amp;gt;= today()-30; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;since i am using the same dataset to create two datasets as two different datasets, Is there a way to create a single proc sql code to accomplish the task I am trying to do?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 04:13:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413562#M101244</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-11-15T04:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql to create two datasets from one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413565#M101246</link>
      <description>&lt;P&gt;One proc sql cannot create 2 datasets. You need to use a datastep with output to different datasets.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 04:48:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413565#M101246</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-11-15T04:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql to create two datasets from one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413570#M101249</link>
      <description>&lt;P&gt;Something like this perhaps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *, 
       sum(amount) as month_sum,
       calculated month_sum - two_sum as balance
from (
    select *,
        intck('day15', date, today(), "CONTINUOUS") as d15Period,
        sum(amount) as two_sum
    from have
    where calculated d15Period &amp;lt;2
    group by calculated d15Period )
;
select * from want;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Nov 2017 05:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413570#M101249</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-11-15T05:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql to create two datasets from one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413604#M101260</link>
      <description>&lt;P&gt;Yes, there is a way, use a datastep - with that you can process the data in one datastep and output two datasets.&amp;nbsp; SQL only has to be used when being passed through to a database, otherwise you can use datastep or SQL for any problem.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 10:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413604#M101260</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-15T10:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql to create two datasets from one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413641#M101268</link>
      <description>&lt;P&gt;Sorry for late response. I would try recommended code. Thanks all for helping me out here.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 13:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413641#M101268</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-11-15T13:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql to create two datasets from one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413647#M101272</link>
      <description>&lt;P&gt;Two datasets are not needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a new column&amp;nbsp;where rec_amount is missing if the data is not in the last 2 weeks; and create another new column where rec_amount is missing if the data is not from the last month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, PROC SUMMARY can compute the sums or means for the desired time periods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
     var last2weeks lastmonth;
     output out=stats sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Nov 2017 13:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413647#M101272</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-15T13:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql to create two datasets from one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413882#M101351</link>
      <description>&lt;P&gt;Thanks for the replies. I appreciate your help.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 04:21:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-to-create-two-datasets-from-one-dataset/m-p/413882#M101351</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-11-16T04:21:37Z</dc:date>
    </item>
  </channel>
</rss>

