<?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: Partial date query in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/701515#M214825</link>
    <description>&lt;P&gt;The question is a string comparison question and only involves strings that look like calendar values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps this will help&lt;/P&gt;
&lt;PRE&gt;proc sql ;
create table ck as
select * from (
  select date,
    case 
      when length (date) =  4 and date &amp;lt; "2020"       then "&amp;lt; 2020"
      when length (date) =  7 and date &amp;lt; "2020-10"    then "&amp;lt; 2020-10"
      when length (date) = 10 and date &amp;lt; "2020-10-09" then "&amp;lt; 2020-10-09"
      when date = "" then ""
      else "invalid"
    end as xyz
    from abc
) get_me_out_of_this_asylum
where xyz ne "invalid" ;
quit;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RichardADeVenezia_1-1606309963257.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51991i37E63A829FCFB1F4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RichardADeVenezia_1-1606309963257.png" alt="RichardADeVenezia_1-1606309963257.png" /&gt;&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, 25 Nov 2020 13:16:10 GMT</pubDate>
    <dc:creator>RichardDeVen</dc:creator>
    <dc:date>2020-11-25T13:16:10Z</dc:date>
    <item>
      <title>Partial date query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/701476#M214820</link>
      <description>&lt;P&gt;/* My requirement final data in new variable should consist of blank records and less then "2020" , "2020-10" , "2020-10-09" */&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data abc ;&lt;BR /&gt;date = "2020-10-09"; output ;&lt;BR /&gt;date = "2009"; output ;&lt;BR /&gt;date = "2020-08"; output ;&lt;BR /&gt;date = "2020-09"; output ;&lt;BR /&gt;date = "2020-10"; output ;&lt;BR /&gt;date = "2020-10-08"; output ;&lt;BR /&gt;date = ""; output ;&lt;BR /&gt;date = "2020-10-07"; output ;&lt;BR /&gt;date = "2020"; output ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;/******This is my approch which I am not satisfied with.*******/&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql ;&lt;BR /&gt;create table ck as&lt;BR /&gt;select * from (select date, &lt;BR /&gt;case when length (date) = 4 and date &amp;lt; "2020" then date&lt;BR /&gt;when length (date) = 7 and date &amp;lt; "2020-10" then date&lt;BR /&gt;when length (date) = 10 and date &amp;lt; "2020-10-09" then date&lt;BR /&gt;when date = "" then ""&lt;BR /&gt;else "invalid"&lt;BR /&gt;end as xyz &lt;BR /&gt;from abc ) where xyz ne "invalid" ;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take care&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 11:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/701476#M214820</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-11-25T11:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Partial date query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/701484#M214821</link>
      <description>&lt;P&gt;Please state why you are unhappy with the results. Show us the desired results.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 11:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/701484#M214821</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-25T11:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Partial date query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/701515#M214825</link>
      <description>&lt;P&gt;The question is a string comparison question and only involves strings that look like calendar values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps this will help&lt;/P&gt;
&lt;PRE&gt;proc sql ;
create table ck as
select * from (
  select date,
    case 
      when length (date) =  4 and date &amp;lt; "2020"       then "&amp;lt; 2020"
      when length (date) =  7 and date &amp;lt; "2020-10"    then "&amp;lt; 2020-10"
      when length (date) = 10 and date &amp;lt; "2020-10-09" then "&amp;lt; 2020-10-09"
      when date = "" then ""
      else "invalid"
    end as xyz
    from abc
) get_me_out_of_this_asylum
where xyz ne "invalid" ;
quit;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RichardADeVenezia_1-1606309963257.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51991i37E63A829FCFB1F4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RichardADeVenezia_1-1606309963257.png" alt="RichardADeVenezia_1-1606309963257.png" /&gt;&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, 25 Nov 2020 13:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/701515#M214825</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-11-25T13:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Partial date query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/702037#M215008</link>
      <description>I am happy with result , i am not happy with my program.</description>
      <pubDate>Fri, 27 Nov 2020 14:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/702037#M215008</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-11-27T14:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Partial date query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/702038#M215009</link>
      <description>This is not desired output. Check my program output data.</description>
      <pubDate>Fri, 27 Nov 2020 14:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/702038#M215009</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-11-27T14:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Partial date query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/702079#M215027</link>
      <description>&lt;P&gt;Why does the query have a sub-select ? Is that what you are unhappy with ?&amp;nbsp; What streamlined query do you intuitively feel could be written ?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 17:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/702079#M215027</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-11-27T17:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Partial date query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/702148#M215046</link>
      <description>I was looking without "invalid" data. filtering of invalid data which is annoying to me. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Sat, 28 Nov 2020 02:50:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-date-query/m-p/702148#M215046</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-11-28T02:50:06Z</dc:date>
    </item>
  </channel>
</rss>

