<?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: Selecting dates using where statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758217#M239373</link>
    <description>&lt;P&gt;You're right, thank you. I was also missing the lowercase 'd'. For my learning, why is that necessary if the dates are already SAS formatted? Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Jul 2021 19:04:15 GMT</pubDate>
    <dc:creator>EmilyAV</dc:creator>
    <dc:date>2021-07-29T19:04:15Z</dc:date>
    <item>
      <title>Selecting dates using where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758207#M239371</link>
      <description>&lt;P&gt;I have a very large dataset that significantly slows down my processing speed.&lt;/P&gt;&lt;P&gt;Therefore, before I do any work with the data, I'd like to reduce its size by creating a smaller dataset that only contains entries made after a specific date. The dates are already in MMDDYY8. format, but I can't figure out how to specify dates on or after that date (February 3, 2014 in this example) using the WHERE statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data small;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set large;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;where date_variable &amp;gt;= '023014';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Most of the examples I have found have used SQL or first adapted the date to an SAS informat, so I'm not sure whether the problem is the format I'm entering or something else. I've also tried to enter the date converted to the SAS day code without success. Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much,&lt;/P&gt;&lt;P&gt;Emily&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 18:52:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758207#M239371</guid>
      <dc:creator>EmilyAV</dc:creator>
      <dc:date>2021-07-29T18:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting dates using where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758212#M239372</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where date_variable &amp;gt;= '03FEB2014'd;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your words talk about FEB 3 but your example code looks for FEB 30 (which doesn't exist), I assume you really wanted FEB 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The format of the variable is irrelevant to creating the code. &lt;FONT face="courier new,courier"&gt;'03FEB2014'd&lt;/FONT&gt; will work regardless of the format.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 19:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758212#M239372</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-29T19:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting dates using where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758217#M239373</link>
      <description>&lt;P&gt;You're right, thank you. I was also missing the lowercase 'd'. For my learning, why is that necessary if the dates are already SAS formatted? Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 19:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758217#M239373</guid>
      <dc:creator>EmilyAV</dc:creator>
      <dc:date>2021-07-29T19:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting dates using where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758219#M239374</link>
      <description>Because you can have a variable as text or numeric. The d tells SAS to interpret it not as a constant or character value but as a date value. &lt;BR /&gt;&lt;BR /&gt;Another option is to use the MDY() function. &lt;BR /&gt;&lt;BR /&gt;where date_variable &amp;gt; mdy(2, 3, 2014)</description>
      <pubDate>Thu, 29 Jul 2021 19:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758219#M239374</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-29T19:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting dates using where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758222#M239375</link>
      <description>&lt;P&gt;Formats change the appearance to us humans. SAS represents the date internally as the number of days since 01JAN1960. So for example, 01JAN2020 is 21915 to SAS. Humans can type this as '01JAN2020'd, you don't have to know that it's 21915.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the format can make it appear as 01JAN2020 or 2020-01-01 or many other appearances. Regardless of the appearance, SAS performs operations on the internal representation (01JAN2020 is represented as 21915) and so these are all equivalent&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_variable&amp;gt;21915
date_variable&amp;gt;'01JAN2020'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;because both are 21915 to SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These will not work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_variable&amp;gt;20200101
date_variable&amp;gt;2020-01-01&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;because neither of these is 21915 to SAS.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 19:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758222#M239375</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-29T19:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting dates using where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758223#M239376</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391598"&gt;@EmilyAV&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You're right, thank you. I was also missing the lowercase 'd'. For my learning, why is that necessary if the dates are already SAS formatted? Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS uses a single data literal format, the Date9 (or date7),&amp;nbsp; such as 03Feb2021 because&amp;nbsp; 010203 could be: Jan 2 2003(or 1903), 1 Feb 2003, or 2001 Feb 03. With the single format then the program does not have to attempt to guess which date layout is intended.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 19:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758223#M239376</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-29T19:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting dates using where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758225#M239377</link>
      <description>This is all documented here:&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/p0cq7f0icfjr8vn19vyunwmmsl7m.htm#:~:text=A%20SAS%20constant%20is%20a,Constants%20are%20also%20called%20literals%20" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/p0cq7f0icfjr8vn19vyunwmmsl7m.htm#:~:text=A%20SAS%20constant%20is%20a,Constants%20are%20also%20called%20literals%20&lt;/A&gt;.</description>
      <pubDate>Thu, 29 Jul 2021 19:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758225#M239377</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-29T19:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting dates using where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758227#M239378</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391598"&gt;@EmilyAV&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A Format typically only affects how you&amp;nbsp;&lt;EM&gt;see&amp;nbsp;&lt;/EM&gt;the data.&amp;nbsp; How it is&amp;nbsp;&lt;EM&gt;stored&lt;/EM&gt; internal to SAS is still a number (the count of days since Jan 1, 1960).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take a look at this little SAS dataset.&amp;nbsp; In the Application_Date column what you&amp;nbsp;&lt;EM&gt;see&lt;/EM&gt; is YYMMDDD10. formatted.&amp;nbsp; However, notice the little icon for that column.&amp;nbsp; It's a little calendar; in other words, it's a date.&amp;nbsp; It is not a character value of '2021-07-28'.&amp;nbsp; Look at the column to the left of it, Applicant_Name.&amp;nbsp; Notice the icon, a little cone with the letter "A" for alphanumeric (character) data.&amp;nbsp; The icons are not the same even though you&amp;nbsp;&lt;EM&gt;see&lt;/EM&gt; what looks like character data in the Application_Date.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Think of a Format like a pair of sunglasses.&amp;nbsp; When you put on the glasses, yes, the world &lt;EM&gt;looks&lt;/EM&gt; different (depending on the tint, prescription, polarization, etc.), but it's not that the world has actually changed.&amp;nbsp; Just what you&amp;nbsp;&lt;EM&gt;see&lt;/EM&gt; has changed.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1627585917360.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62100i628D12EE679E597B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jimbarbour_0-1627585917360.png" alt="jimbarbour_0-1627585917360.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 19:16:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758227#M239378</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-07-29T19:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting dates using where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758230#M239379</link>
      <description>&lt;P&gt;SAS has two types of variables.&amp;nbsp; Fixed length character strings and floating point numbers.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the first thing you need to check is whether your variable is numeric or character.&amp;nbsp; Then if it is numeric whether it has a format attached that being used to specify how to display the floating point numbers as character strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the variable has date values then it has the number of days since 1960 storing in it.&amp;nbsp; The format is what makes that number meaning full to humans.&amp;nbsp; So if the date is the third of February in the year 2014 then the value stored is the number&amp;nbsp;19,757.&amp;nbsp; If you display that number with the DATE9. format it will look like 03FEB2014.&amp;nbsp; If you display it with the MMDDYY&lt;STRONG&gt;N&lt;/STRONG&gt;8. it will look like 02032014.&amp;nbsp; If you display it with MMDDYY10. format it will look like 02-03-2014.&amp;nbsp; If you display it with the format you mentioned, MMDDYY8., then it will look like 02-03-14.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to type a date value into your program you can use a date literal.&amp;nbsp; That is a quoted string with the letter d appended.&amp;nbsp; The string inside the quotes needs to be something the DATE informat can interpret as a date.&amp;nbsp; So use one of these values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'03FEB2014'd
'3-feb-2014'd
"03feb14"d&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Jul 2021 19:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-dates-using-where-statement/m-p/758230#M239379</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-29T19:18:12Z</dc:date>
    </item>
  </channel>
</rss>

