<?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: Date range based on a differ date in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400845#M66734</link>
    <description>Thanks for response .. here is exampke of my proc table&lt;BR /&gt;Proc sql;&lt;BR /&gt;Create table table1 as&lt;BR /&gt;(Select&lt;BR /&gt;Id,&lt;BR /&gt;Conversion_date,&lt;BR /&gt;Conversion_date -90 fornat mmddyy9. As date&lt;BR /&gt;From part1&lt;BR /&gt;);&lt;BR /&gt;Run;&lt;BR /&gt;Output&lt;BR /&gt;Id. Conversion_date. Date&lt;BR /&gt;A1. 25sep2017. 06/27/17&lt;BR /&gt;q1. 07Aug2017. 05/09/17&lt;BR /&gt;d2. 26Jun2017. 03/28/17&lt;BR /&gt;Here is the tricky part&lt;BR /&gt;How can i use date col date from table1 an apply it to a 3rd table as my start date the 3rd table looks like this&lt;BR /&gt;Proc sql;&lt;BR /&gt;Create table part3 as&lt;BR /&gt;(SELECT&lt;BR /&gt;ID ,&lt;BR /&gt;TRANDATE&lt;BR /&gt;From report7&lt;BR /&gt;where transdate between (ts '2017-07-01 00:00:00.000') and (ts ' 2017-07-31 00:00;00:000')&lt;BR /&gt;Wht i woild wNt is the start date to be the date from table 1&lt;BR /&gt;transdate between (ts '2017-06-27 00:00:00.000') and (ts ' 2017-07-31 00:00;00:000')&lt;BR /&gt;&lt;BR /&gt;transdate between (ts '2017-05-09 00:00:00.000') and (ts ' 2017-07-31 00:00;00:000')&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 04 Oct 2017 00:34:37 GMT</pubDate>
    <dc:creator>Gil_</dc:creator>
    <dc:date>2017-10-04T00:34:37Z</dc:date>
    <item>
      <title>Date range based on a differ date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400814#M66731</link>
      <description>Hi i have a table that shows&lt;BR /&gt;Proc sql ;&lt;BR /&gt;Create table part1 as&lt;BR /&gt;(Select&lt;BR /&gt;Id,&lt;BR /&gt;From table&lt;BR /&gt;);&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I join it with another table that has id and a con date&lt;BR /&gt;I did a -90 days from the conversion day eq date table looks like below table name is report1&lt;BR /&gt;&lt;BR /&gt;Id conversion_date date&lt;BR /&gt;A1. 25sep2017. 06/27/17&lt;BR /&gt;b1. O7Aug2017. 05/09/17&lt;BR /&gt;&lt;BR /&gt;I have that the part i need help is i now need to use date as my refer&lt;BR /&gt;For a date range here is what i have&lt;BR /&gt;Data _null_ ; start_date= today () -1;&lt;BR /&gt;End_date = today -90;&lt;BR /&gt;Call symput ('dt', " ' "||put (start_date, date.)||" ' ");&lt;BR /&gt;Call symput ('dt1', " ' "||put (end_date, date.)||" ' ");&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I than refer that with a between dt and dt1&lt;BR /&gt;i need to have my start date&lt;BR /&gt;Refer report1 date some thing like&lt;BR /&gt;between 06/27/27 and 10/02/17&lt;BR /&gt;between 05/09/17 and 10/02/17&lt;BR /&gt;Thank you for assistance&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Oct 2017 21:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400814#M66731</guid>
      <dc:creator>Gil_</dc:creator>
      <dc:date>2017-10-03T21:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Date range based on a differ date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400834#M66732</link>
      <description>&lt;P&gt;It might help to provide an example of your starting data and what is needed at the end, dummy values are fine as long as they illustrate the entire process, Best is to post data step code to create the data so we know all of the actual variable names and types and can write code against your example. Paste the data step code into a code box opened with the forum {I} menu icon as some code pasted into the main message windows here gets reformatted and will not run accurately when copied into a SAS session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There should be no need that I see from your example for any macro variables.&lt;/P&gt;
&lt;P&gt;You should be able to use something like: where (today() - 90) &amp;lt; datevariablename &amp;lt; (today() - 1)&lt;/P&gt;
&lt;P&gt;or the le if you don't want strictly less than. If you are using the actual Between clause in SQL the above would work with&lt;/P&gt;
&lt;P&gt;between (today() - 90)&amp;nbsp;and (today() - 1)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you say :&lt;/P&gt;
&lt;P&gt;between 06/27/27 and 10/02/17&lt;BR /&gt;between 05/09/17 and 10/02/17&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is between those dates? A variable, what is it's name? Is a character variable? If the variable is character than a "between" comparison is likely to fail as 07/15/04 will be between 05/09/17 and 10/02/17 because 07 is after 05 but before 10 in character comparisons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the variable is a SAS date then you do not want to use a character comparison value at all and a human readable literal for dates would be in the form '15Jul2017'd.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you trying to do something in a different database like Oracle or DB2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2017 22:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400834#M66732</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-03T22:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Date range based on a differ date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400845#M66734</link>
      <description>Thanks for response .. here is exampke of my proc table&lt;BR /&gt;Proc sql;&lt;BR /&gt;Create table table1 as&lt;BR /&gt;(Select&lt;BR /&gt;Id,&lt;BR /&gt;Conversion_date,&lt;BR /&gt;Conversion_date -90 fornat mmddyy9. As date&lt;BR /&gt;From part1&lt;BR /&gt;);&lt;BR /&gt;Run;&lt;BR /&gt;Output&lt;BR /&gt;Id. Conversion_date. Date&lt;BR /&gt;A1. 25sep2017. 06/27/17&lt;BR /&gt;q1. 07Aug2017. 05/09/17&lt;BR /&gt;d2. 26Jun2017. 03/28/17&lt;BR /&gt;Here is the tricky part&lt;BR /&gt;How can i use date col date from table1 an apply it to a 3rd table as my start date the 3rd table looks like this&lt;BR /&gt;Proc sql;&lt;BR /&gt;Create table part3 as&lt;BR /&gt;(SELECT&lt;BR /&gt;ID ,&lt;BR /&gt;TRANDATE&lt;BR /&gt;From report7&lt;BR /&gt;where transdate between (ts '2017-07-01 00:00:00.000') and (ts ' 2017-07-31 00:00;00:000')&lt;BR /&gt;Wht i woild wNt is the start date to be the date from table 1&lt;BR /&gt;transdate between (ts '2017-06-27 00:00:00.000') and (ts ' 2017-07-31 00:00;00:000')&lt;BR /&gt;&lt;BR /&gt;transdate between (ts '2017-05-09 00:00:00.000') and (ts ' 2017-07-31 00:00;00:000')&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Oct 2017 00:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400845#M66734</guid>
      <dc:creator>Gil_</dc:creator>
      <dc:date>2017-10-04T00:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Date range based on a differ date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400854#M66736</link>
      <description>&lt;P&gt;Sorry, that's not really very clear.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 03:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400854#M66736</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-04T03:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Date range based on a differ date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400861#M66737</link>
      <description>Sorry i wish could start anew with a new question.&lt;BR /&gt;In the most straight forward way i have a table1&lt;BR /&gt;Id. conversion _date. Date&lt;BR /&gt;A1. 25sep2017. 06/27/17&lt;BR /&gt;q1. 07Aug2017. . 05/09/17&lt;BR /&gt;d2. 26Jun2017. 03/28/17&lt;BR /&gt;&lt;BR /&gt;Thats how my table looks the tricky part i have a 2nd table&lt;BR /&gt;&lt;BR /&gt;Proc sql;&lt;BR /&gt;Create table part3 as&lt;BR /&gt;(SELECT&lt;BR /&gt;ID ,&lt;BR /&gt;TRANDATE&lt;BR /&gt;From report7&lt;BR /&gt;where transdate between (ts '2017-07-01 00:00:00.000') and (ts ' 2017-07-31 00:00;00:000')&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Thats how the table looks .. what i want to do is use the col date from table1 in the place of the start time and end time would be yesterday date. For example&lt;BR /&gt;where transdate between (ts '2017-06-27 00:00:00.000') and (ts ' 2017-10-02 00:00;00:000')&lt;BR /&gt;&lt;BR /&gt;So the range will be differ dependind on what's on table1 col name Date ... not sure if its is a loop or Macro to close to 4k entries with a differ start time same end time -1 ..</description>
      <pubDate>Wed, 04 Oct 2017 06:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400861#M66737</guid>
      <dc:creator>Gil_</dc:creator>
      <dc:date>2017-10-04T06:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Date range based on a differ date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400876#M66738</link>
      <description>&lt;P&gt;Sorry, its really not clear to me either, &lt;SPAN&gt;show the test data in the form of a dataset and show what the output should look like&lt;/SPAN&gt;. You have one dataset with three rows and for each of those rows you want to extract data into a new dataset?&amp;nbsp; Thats what you seem to be saying, maybe it is based on ID?&amp;nbsp; If so then you can just merge the first dataset onto the second by id and then use the date as you would any other time.&amp;nbsp; Example below (and do notice i correct the SQL code:&lt;/P&gt;
&lt;PRE&gt;data table1;
  id="A1"; conversion_date="25sep2017"d; output;
  id="q1"; conversion_date="07aug2017"d; output;
run;

proc sql;
  create table PART3 as
  select  A.ID,
          A.TRANDATE
  from    REPORT7 A
  left join TABLE1 B
  on      A.ID=B.ID
  where   A.TRANDATE between B.CONVERSION_DATE and today()-1;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Oct 2017 08:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-based-on-a-differ-date/m-p/400876#M66738</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-04T08:27:10Z</dc:date>
    </item>
  </channel>
</rss>

