<?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: Create variables for dates based on another column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-variables-for-dates-based-on-another-column/m-p/762689#M241500</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393992"&gt;@temsandroses&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to pull data from oracle based on the 3 columns from the input file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;start_date| end_date | title&lt;/P&gt;
&lt;P&gt;01aug2021 | 01oct2021| 2021 Batch 1&lt;/P&gt;
&lt;P&gt;01jul2021 | 01oct2021| 2021 Batch 2&lt;/P&gt;
&lt;P&gt;01jun2021 | 01oct2021| 2021 Batch 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each title I want to obtain data for each day only within the start and end date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to do so?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And what does "data for each day only within the start and end date" look like?&lt;/P&gt;
&lt;P&gt;I'm not sure the "example" shown is the input or the output. If the input, what is the output supposed to look like?&lt;/P&gt;
&lt;P&gt;If that is the output then what does the input look like?&lt;/P&gt;</description>
    <pubDate>Thu, 19 Aug 2021 20:37:53 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-08-19T20:37:53Z</dc:date>
    <item>
      <title>Create variables for dates based on another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variables-for-dates-based-on-another-column/m-p/762675#M241494</link>
      <description>&lt;P&gt;I am trying to pull data from oracle based on the 3 columns from the input file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;start_date| end_date | title&lt;/P&gt;&lt;P&gt;01aug2021 | 01oct2021| 2021 Batch 1&lt;/P&gt;&lt;P&gt;01jul2021 | 01oct2021| 2021 Batch 2&lt;/P&gt;&lt;P&gt;01jun2021 | 01oct2021| 2021 Batch 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each title I want to obtain data for each day only within the start and end date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do so?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 20:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variables-for-dates-based-on-another-column/m-p/762675#M241494</guid>
      <dc:creator>temsandroses</dc:creator>
      <dc:date>2021-08-19T20:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create variables for dates based on another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variables-for-dates-based-on-another-column/m-p/762684#M241497</link>
      <description>&lt;P&gt;This worked for me:&lt;/P&gt;
&lt;P&gt;Setup some test data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   infile datalines dsd dlm='|';
   input start_date:date9. end_date:date9. title:$50.;
   format start_date end_date date9.;
datalines;
01aug2021 | 01oct2021| 2021 Batch 1
01jul2021 | 01oct2021| 2021 Batch 2
01jun2021 | 01oct2021| 2021 Batch 3
;

libname db oracle user=student pw=Metadata0;
data db.Titles;
   if _n_=1 then call streaminit(12345);
   set have;
   output;
   do i= 1 to rand('integer',1,5);
      start_date=sum(start_date,rand('integer',1,5));
      end_date=sum(start_date,rand('integer',1,3));
      output;
   end;
   drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then this SQL join did the trick:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select db.* 
   from work.have as h
        inner join 
        db.Titles as db
        on db.title=h.title
          and datepart(db.start_date)=h.start_date
          and datepart(db.end_date)=h.end_date
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure SQL: Query Results" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;START_DATE&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;END_DATE&lt;/TH&gt;
&lt;TH class="l b header" scope="col"&gt;TITLE&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;01AUG2021:00:00:00&lt;/TD&gt;
&lt;TD class="r data"&gt;01OCT2021:00:00:00&lt;/TD&gt;
&lt;TD class="l data"&gt;2021 Batch 1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;01JUL2021:00:00:00&lt;/TD&gt;
&lt;TD class="r data"&gt;01OCT2021:00:00:00&lt;/TD&gt;
&lt;TD class="l data"&gt;2021 Batch 2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;01JUN2021:00:00:00&lt;/TD&gt;
&lt;TD class="r data"&gt;01OCT2021:00:00:00&lt;/TD&gt;
&lt;TD class="l data"&gt;2021 Batch 3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 19 Aug 2021 20:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variables-for-dates-based-on-another-column/m-p/762684#M241497</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2021-08-19T20:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create variables for dates based on another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variables-for-dates-based-on-another-column/m-p/762689#M241500</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393992"&gt;@temsandroses&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to pull data from oracle based on the 3 columns from the input file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;start_date| end_date | title&lt;/P&gt;
&lt;P&gt;01aug2021 | 01oct2021| 2021 Batch 1&lt;/P&gt;
&lt;P&gt;01jul2021 | 01oct2021| 2021 Batch 2&lt;/P&gt;
&lt;P&gt;01jun2021 | 01oct2021| 2021 Batch 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each title I want to obtain data for each day only within the start and end date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to do so?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And what does "data for each day only within the start and end date" look like?&lt;/P&gt;
&lt;P&gt;I'm not sure the "example" shown is the input or the output. If the input, what is the output supposed to look like?&lt;/P&gt;
&lt;P&gt;If that is the output then what does the input look like?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 20:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variables-for-dates-based-on-another-column/m-p/762689#M241500</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-19T20:37:53Z</dc:date>
    </item>
  </channel>
</rss>

