<?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: Using a date lookup table with a condition when the date is formatted as a character. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295187#M60109</link>
    <description>&lt;P&gt;The preferre way of using lookup tables for filtering is by using SQL inner joins. The is the usual technique when dealing with star schemas, and similar.&lt;/P&gt;
&lt;P&gt;But since your date in the date lookup table (dimension?) is char, you can't use a SAS date constant, since that is considered&amp;nbsp;as numeric.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could probably use the same date char format as your lookup table, even if it's not ideal. Is the data stored in SAS data sets?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2016 14:28:44 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2016-08-30T14:28:44Z</dc:date>
    <item>
      <title>Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295175#M60108</link>
      <description>&lt;P&gt;Hi There.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've started using a new DWH at work and they've introduced lookup tabels for practically everything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a large dataset&amp;nbsp;that contains a number (key) that links to a date that SAS is reading as character (theyre using SQL and dont know why its not recognising it as a date)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want to do conditionally search the large table by date so for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lookup table has two variables (date is formatted as character)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DateKey &amp;nbsp; &amp;nbsp; TranDate&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;2016-01-01&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &lt;SPAN&gt;2016-01-02&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;&lt;SPAN&gt;2016-01-02&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data set has numerous variables, one being the datekey which is formated as 6.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want to merge them together but might add a condition such as:-&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Where = (Trandate &amp;gt;= '01Jan2016'd);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;is this possible? the only way I can do it is to read the entire dataset in then merge it with the lookup table but this obviously takes time due to the size of the table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any help greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 14:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295175#M60108</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-30T14:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295187#M60109</link>
      <description>&lt;P&gt;The preferre way of using lookup tables for filtering is by using SQL inner joins. The is the usual technique when dealing with star schemas, and similar.&lt;/P&gt;
&lt;P&gt;But since your date in the date lookup table (dimension?) is char, you can't use a SAS date constant, since that is considered&amp;nbsp;as numeric.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could probably use the same date char format as your lookup table, even if it's not ideal. Is the data stored in SAS data sets?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 14:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295187#M60109</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-08-30T14:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295206#M60110</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The preferre way of using lookup tables for filtering is by using SQL inner joins. The is the usual technique when dealing with star schemas, and similar.&lt;/P&gt;
&lt;P&gt;But since your date in the date lookup table (dimension?) is char, you can't use a SAS date constant, since that is considered&amp;nbsp;as numeric.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could probably use the same date char format as your lookup table, even if it's not ideal. Is the data stored in SAS data sets?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do have a piece of code that will change the character dates to an actual date format, as the lookup table only consists of about 10000 observations I dont think this would take too long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I did this and the date was in mmddyy10. could I then use the SQL inner join?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so would you able to provide an example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Really apprecate the help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 14:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295206#M60110</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-30T14:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295209#M60111</link>
      <description>&lt;P&gt;A few notes ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your character date is in Y-M-D form, you can compare to it directly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where = (TranDate &amp;gt;= '2016-01-01')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to compare these character values to the numeric values in a larger data set, that can be done as well.&amp;nbsp; But it's not clear what that other data set contains.&amp;nbsp; Does it contain numeric dates, numeric datetimes, something else entirely?&amp;nbsp; What would it contain that lets it be joined to your lookup table in any way?&amp;nbsp; DATEKEY?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 15:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295209#M60111</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-30T15:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295219#M60112</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;A few notes ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your character date is in Y-M-D form, you can compare to it directly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where = (TranDate &amp;gt;= '2016-01-01')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to compare these character values to the numeric values in a larger data set, that can be done as well.&amp;nbsp; But it's not clear what that other data set contains.&amp;nbsp; Does it contain numeric dates, numeric datetimes, something else entirely?&amp;nbsp; What would it contain that lets it be joined to your lookup table in any way?&amp;nbsp; DATEKEY?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apologies if didnt make it clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ok so both tables have a variable called DateKey which is a number and the lookupdate contains the date ( i've just converted the dates in the lookup to mmddyy10. so the character thing isnt an issue now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I would like to do is join the tabkes together by the variable datekey but only bring back obersvations from the non lookuptable where date &amp;gt;= 01Jan16 etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The non lookup table has millions of observations so i need to make sure that in the step im joining the tables together I am able to&amp;nbsp;define some conditional criteria.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That make sense?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 15:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295219#M60112</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-30T15:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295221#M60113</link>
      <description>&lt;P&gt;Here are the pieces that I'm not sure about.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you say you converted the lookup dates to mmddyy10 format, what does that mean?&amp;nbsp; Do you have an actual SAS date value (numeric) stored there, with a format applied for printing purposes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you have a DATE variable in the nonlookup table, what does it contain?&amp;nbsp; A date value on the SAS date scale?&amp;nbsp; A datetime value?&amp;nbsp; A character string?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 15:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295221#M60113</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-30T15:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295225#M60114</link>
      <description>&lt;P&gt;Hi. Heres the tables i have&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lookup Table... Datekey is a numerical format, date is now in dateformat&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DateKey &amp;nbsp; &amp;nbsp; Date&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01/01/2016&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02/01/2016&lt;/P&gt;
&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03/01/2016&lt;/P&gt;
&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 04/01/2016&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transaction Table Contains multiple variables however also contains the DateKey&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DateKey &amp;nbsp;Var2 Var3 Var4&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to join the two tables by datekey but i'd like to include the statment where the date in the joined table is = 03/01/2016. (or any other condition of my choosing)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not 100% sure if this is possible&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Help continues to be appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 15:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295225#M60114</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-30T15:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295228#M60116</link>
      <description>&lt;P&gt;Do I understand right:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if TRANDATE was in a SAS date (numeric) format&lt;/P&gt;&lt;P&gt;then you will use : &lt;STRONG&gt;&amp;nbsp;Where = (Trandate &amp;gt;= '01Jan2016'd);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As&amp;nbsp;TRANDATE is a character variable you can use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where = (input(trandate,yymmdd10.) &amp;gt;= '01JAN2016'd);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 15:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295228#M60116</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-08-30T15:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295229#M60117</link>
      <description>&lt;P&gt;I must be having a slow day.&amp;nbsp; Here's the part I still don't understand:&amp;nbsp; "date is now in dateformat"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is actually contained in the field DATE?&amp;nbsp; A character string?&amp;nbsp; A numeric value on the SAS date scale?&amp;nbsp; A numeric value on some other scale that your data warehouse uses?&amp;nbsp; A numeric value that corresponds to a date-time rather than a date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whatever the answer, if you want to compare with date fields in the non-lookup table(s), the same questions will apply to those date fields.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 15:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295229#M60117</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-30T15:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295287#M60122</link>
      <description>Sorry it's my terminology.&lt;BR /&gt;&lt;BR /&gt;So it's a sas date scale, a number given a format to show a proper date. This date is only in the lookup table. However both tables have a datekey this key is what the two tables need to be merged by however i only want the tables to merge data where the date is after a certain date.&lt;BR /&gt;&lt;BR /&gt;As the actual date is only in the lookup table I'm not sure if this is possible.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Aug 2016 19:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295287#M60122</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-30T19:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295294#M60123</link>
      <description>&lt;P&gt;OK, I think I'm starting to understand the issues here.&amp;nbsp; You can't use a standalone WHERE statement, since the date field appears in only one data set.&amp;nbsp; This program would require the date to be in both data sets:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge huge_table (in=in1) lookup_table (in=in2);&lt;/P&gt;
&lt;P&gt;by datekey;&lt;/P&gt;
&lt;P&gt;if in1 and in2;&lt;/P&gt;
&lt;P&gt;where TranDate &amp;gt;= '01Mar2016'd;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That would generate an error, because TranDate doesn't appear in HUGE_TABLE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, use the WHERE clause as a data set modifier:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge huge_table (in=in1) lookup_table (in=in2 where=(TranDate &amp;gt;= '01Mar2016'd));&lt;/P&gt;
&lt;P&gt;by datekey;&lt;/P&gt;
&lt;P&gt;if in1 and in2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All of this assumes you're actually using MERGE to combine the data ... if you are using SQL it can be done but would look a bit different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are we finally headed in the right direction?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 19:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295294#M60123</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-30T19:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295296#M60124</link>
      <description>&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; create table want as select&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; a.*, b.* &amp;nbsp; /* change to desired variables */&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;from lookup_table(where=(date='03JAN2016'd)) as a&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;left &amp;nbsp;join transaction_table as b&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;on (a.date_key = b.datekey)&lt;/P&gt;&lt;P&gt;&amp;nbsp; ; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that what you want ? if not addapt it to your needs.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 19:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295296#M60124</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-08-30T19:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295298#M60125</link>
      <description>I think we are heading in the right direction my friend.&lt;BR /&gt;&lt;BR /&gt;I'm not at work at the moment but ill give them a shot tomorrow.&lt;BR /&gt;&lt;BR /&gt;Will report back.&lt;BR /&gt;&lt;BR /&gt;Thanks again</description>
      <pubDate>Tue, 30 Aug 2016 19:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295298#M60125</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-30T19:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295400#M60128</link>
      <description>&lt;P&gt;Ok had a pop at this this morning&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table want as select&lt;BR /&gt; a.DateKey, b.Date /* change to desired variables */&lt;BR /&gt; from DateKey(where=(date&amp;gt;'03JAN2016'd)) as a&lt;BR /&gt; left join Payments as b&lt;BR /&gt; on (a.Datekey = b.Datekey)&lt;BR /&gt; ; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but got this error merssage&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;898 proc sql;&lt;BR /&gt;899 create table want as select&lt;BR /&gt;900 a.DateKey, b.Date /* change to desired variables */&lt;BR /&gt;901 from DateKey(where=(date&amp;gt;'03JAN2016'd)) as a&lt;BR /&gt;902 left join Payments as b&lt;BR /&gt;903 on (a.Datekey = b.Datekey)&lt;BR /&gt;904 ;&lt;BR /&gt;ERROR: Column Date could not be found in the table/view identified with the correlation name B.&lt;BR /&gt;904! quit;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt; real time 0.00 seconds&lt;BR /&gt; cpu time 0.00 seconds&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 06:54:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295400#M60128</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-31T06:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295401#M60129</link>
      <description>&lt;P&gt;Ok changed it to this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table want as select&lt;BR /&gt; a.DateKey,Date, b.DateKey, TransactionAmount/* change to desired variables */&lt;BR /&gt; from DateKey(where=(date&amp;gt;'28Aug2016'd)) as a&lt;BR /&gt; left join Payments as b&lt;BR /&gt; on (a.Datekey = b.Datekey)&lt;BR /&gt; ; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and heres the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;953 proc sql;&lt;BR /&gt;954 create table want as select&lt;BR /&gt;955 a.DateKey,Date, b.DateKey, TransactionAmount/* change to desired variables */&lt;BR /&gt;956 from DateKey(where=(date&amp;gt;'28Aug2016'd)) as a&lt;BR /&gt;957 left join Payments as b&lt;BR /&gt;958 on (a.Datekey = b.Datekey)&lt;BR /&gt;959 ;&lt;BR /&gt;WARNING: Variable DateKey already exists on file WORK.WANT.&lt;BR /&gt;NOTE: Table WORK.WANT created, with 223 rows and 3 columns.&lt;/P&gt;
&lt;P&gt;959! quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt; real time 0.02 seconds&lt;BR /&gt; cpu time 0.03 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However while it has merged the transaction amount variable where the dates are &amp;gt; 28/08/2016 it has still brought back the other variables from the lookup table (i.e where the date is &amp;lt; 28/08/2016 its juts put the transaction amount as blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All i want to see is where the date is &amp;gt; 28/08/2016, think we're nearly there though&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 07:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295401#M60129</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-31T07:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295421#M60135</link>
      <description>&lt;P&gt;I woul like to clarify some points:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- is the look_up&amp;nbsp;table named &amp;nbsp;&lt;STRONG&gt;work.datekey&lt;/STRONG&gt; ?&lt;/P&gt;&lt;P&gt;- is the date you want to check is on that work.datekey table and is named &lt;STRONG&gt;DATE&lt;/STRONG&gt; ?&lt;/P&gt;&lt;P&gt;- is the transaction table named as &lt;STRONG&gt;work.payments&lt;/STRONG&gt; ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now back to my oroginal proposed code - addapted to the above:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; create table want as select&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; a.*, b.* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* change to selet desired variables, &amp;nbsp;the asterisk (*) is to select all variables */&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;from &lt;STRONG&gt;work.DateKey&lt;/STRONG&gt; (where=(&lt;STRONG&gt;date&lt;/STRONG&gt;='03JAN2016'd)) as a&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;left &amp;nbsp;join &lt;STRONG&gt;work.payments&lt;/STRONG&gt; as b&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;on (a.date_key = b.datekey)&lt;/P&gt;&lt;P&gt;&amp;nbsp; ; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In case it does not meet your expectations please clarify where and why ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error you got:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR: Column Date could not be found in the table/view identified with the correlation name B.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;is because the DATE variable is not in work.payments table (as &lt;STRONG&gt;B&lt;/STRONG&gt;) &amp;nbsp;but in work.DateKey table (as &lt;STRONG&gt;A&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Don't hesitate to ask more if need.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 08:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295421#M60135</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-08-31T08:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295427#M60138</link>
      <description>&lt;P&gt;Good Morning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Re your comments:-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;- is the look_up&amp;nbsp;table named &amp;nbsp;&lt;STRONG&gt;work.datekey&lt;/STRONG&gt; ? &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/EM&gt;&lt;STRONG&gt;Yes&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;- is the date you want to check is on that work.datekey table and is named &lt;STRONG&gt;DATE&lt;/STRONG&gt; ? &amp;nbsp;&lt;/EM&gt;&lt;STRONG&gt;Yes&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;- is the transaction table named as &lt;STRONG&gt;work.payments&lt;/STRONG&gt; ? &amp;nbsp;&lt;/EM&gt;&lt;STRONG&gt;Ive amended the code slightly, the source table is called &amp;nbsp; &amp;nbsp;=-DWH.vwFactSalaryTransactions&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The last one I ran was this:-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table Payments as select&lt;BR /&gt; a.DateKey, Date, b.DateKey, TransactionAmount, AccountKey, TimeKey, TransactionCodeKey, NarrativeKey, TransactionAmount &lt;BR /&gt; from DateKey(where=(date&amp;gt;'28Aug2016'd)) as a&lt;BR /&gt; left join DWH.vwFactSalaryTransactions as b&lt;BR /&gt; on (a.Datekey = b.Datekey)&lt;BR /&gt; ; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ive then amended it to your most recent code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table Payments as select&lt;BR /&gt; a.*, b.*&lt;BR /&gt; from work.DateKey(where=(date&amp;gt;'28Aug2016'd)) as a&lt;BR /&gt; left join DWH.vwFactSalaryTransactions as b&lt;BR /&gt; on (a.Date_key = b.Datekey)&lt;BR /&gt; ; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to not like "Date_Key"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;45 proc sql;&lt;BR /&gt;46 create table Payments as select&lt;BR /&gt;47 a.*, b.*&lt;BR /&gt;48 from work.DateKey(where=(date&amp;gt;'28Aug2016'd)) as a&lt;BR /&gt;49 left join DWH.vwFactSalaryTransactions as b&lt;BR /&gt;50 on (a.Date_key = b.Datekey)&lt;BR /&gt;51 ;&lt;BR /&gt;ERROR: Column Date_key could not be found in the table/view identified with the correlation name A.&lt;BR /&gt;ERROR: Column Date_key could not be found in the table/view identified with the correlation name A.&lt;BR /&gt;ERROR: Expression using equals (=) has components that are of different data types.&lt;BR /&gt;51 ! quit;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt; real time 0.28 seconds&lt;BR /&gt; cpu time 0.03 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 09:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295427#M60138</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-31T09:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295429#M60140</link>
      <description>&lt;P&gt;So it seems to be merging the data, when I say that, there are exactly 100 observations from the table&amp;nbsp;&lt;SPAN&gt;vwFactSalaryTransactions where the date is &amp;gt; 28/08/2016.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However it is still returning all the dates from the lookup table that are &amp;gt; 28/08/2016 but leaving out the data from&amp;nbsp;vwFactSalaryTransactions.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What i want to do is not retain that data whatsover so the output would be 100 observations&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That make sense?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 09:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295429#M60140</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-31T09:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295432#M60141</link>
      <description>&lt;P&gt;I understand that the key variable on both tables is &lt;STRONG&gt;DateKey.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The error you got tells that&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;Date_key could not be found in&lt;/SPAN&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;SPAN&gt;work.DateKey &amp;nbsp;(&lt;STRONG&gt;A&lt;/STRONG&gt;). &amp;nbsp; Delte the hyphen .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;After running without syntax errors, if you still get&amp;nbsp;observations with date =&amp;lt;&amp;nbsp;'28Aug2016'd&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;then please attach lines from output that you have not expected and the fuul log of your run.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 09:37:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295432#M60141</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-08-31T09:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using a date lookup table with a condition when the date is formatted as a character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295435#M60142</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I understand that the key variable on both tables is &lt;STRONG&gt;DateKey.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The error you got tells that&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;Date_key could not be found in&lt;/SPAN&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;SPAN&gt;work.DateKey &amp;nbsp;(&lt;STRONG&gt;A&lt;/STRONG&gt;). &amp;nbsp; Delte the hyphen .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;After running without syntax errors, if you still get&amp;nbsp;observations with date =&amp;lt;&amp;nbsp;'28Aug2016'd&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;then please attach lines from output that you have not expected and the fuul log of your run.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've attached the output. Ive written a second datastep to just say&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data remove;&lt;BR /&gt; set Payments(Where = (Accountkey ne .));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to remove the records however im sure we should be able to do it in the proq sql statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again thanks for the help.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 09:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-date-lookup-table-with-a-condition-when-the-date-is/m-p/295435#M60142</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2016-08-31T09:46:52Z</dc:date>
    </item>
  </channel>
</rss>

