<?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 format from yyyy-mm-dd to yyyymmdd in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388840#M65970</link>
    <description>&lt;P&gt;Then you have some other issue that you're not showing, my code is correct assuming your variable is character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
length x $10.; format x $10.;
x="20170701";
y = input(x, yymmdd8.);
format y date9.;

if y &amp;lt; "01Jul2017"d then flag=1;
else flag=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Post your full code AND log.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2017 15:03:09 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-08-17T15:03:09Z</dc:date>
    <item>
      <title>Date format from yyyy-mm-dd to yyyymmdd</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388828#M65966</link>
      <description>&lt;P&gt;I want to get all the dates that are less than 20170701 but my date format is in&amp;nbsp;yyyy-mm-dd and so it's a character&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(tc.valid_from,10.) &amp;lt; 20170701&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this code gives me this error message:&amp;nbsp;&lt;SPAN&gt;"An error occured executing the workspace job "Report1". The server is disconnected." if I comment this section out then the project runs fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;help?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm using proc sql and I'd prefer to stay with it but I'll listen to any suggestions! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 14:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388828#M65966</guid>
      <dc:creator>serrld113</dc:creator>
      <dc:date>2017-08-17T14:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Date format from yyyy-mm-dd to yyyymmdd</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388829#M65967</link>
      <description>&lt;P&gt;Are you sure it's a character? If so, use the yymmdd INFORMAT, NOT the 10 format. INPUT uses the format it currently appears in.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should create a SAS date, IMO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(tc.valid_from, yymmdd8.) &amp;lt; '01Jul2017'd &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 14:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388829#M65967</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-17T14:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Date format from yyyy-mm-dd to yyyymmdd</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388832#M65968</link>
      <description>&lt;P&gt;yes, I know it's a character. When I hover over the variable name on the table, there's this little gray "cloud" that describes the variable as such: Type:Character,Length:10,label:Valid_From&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;your suggested code returns error 22-322 Syntax error and error 76-322 &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 14:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388832#M65968</guid>
      <dc:creator>serrld113</dc:creator>
      <dc:date>2017-08-17T14:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Date format from yyyy-mm-dd to yyyymmdd</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388840#M65970</link>
      <description>&lt;P&gt;Then you have some other issue that you're not showing, my code is correct assuming your variable is character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
length x $10.; format x $10.;
x="20170701";
y = input(x, yymmdd8.);
format y date9.;

if y &amp;lt; "01Jul2017"d then flag=1;
else flag=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Post your full code AND log.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 15:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388840#M65970</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-17T15:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Date format from yyyy-mm-dd to yyyymmdd</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388859#M65977</link>
      <description>&lt;P&gt;It sounds like your existing variable is character, including dashes.&amp;nbsp; For that, try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;tc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;valid_from&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; yymmdd10&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="token datetime number"&gt;'01Jul2017'd&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to read 10 characters (not 8).&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 15:44:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388859#M65977</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-17T15:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Date format from yyyy-mm-dd to yyyymmdd</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388882#M65979</link>
      <description>&lt;P&gt;Thank you both. I ended up using this&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tc.valid_from &amp;lt; '01JUL2017'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388882#M65979</guid>
      <dc:creator>serrld113</dc:creator>
      <dc:date>2017-08-17T17:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Date format from yyyy-mm-dd to yyyymmdd</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388884#M65980</link>
      <description>&lt;P&gt;If this is a character variable as you state, &lt;U&gt;&lt;STRONG&gt;you won't get errors but it won't work as you expect&lt;/STRONG&gt;&lt;/U&gt;. It's a character comparison, not a numerical comparison.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/157069"&gt;@serrld113&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thank you both. I ended up using this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tc.valid_from &amp;lt; '01JUL2017'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388884#M65980</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-17T17:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Date format from yyyy-mm-dd to yyyymmdd</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388887#M65981</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, I really appreciate your help. This is in fact a character as I state, and the results are all the dates that I expect. Thank you again for your contribution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388887#M65981</guid>
      <dc:creator>serrld113</dc:creator>
      <dc:date>2017-08-17T17:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Date format from yyyy-mm-dd to yyyymmdd</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388894#M65983</link>
      <description>&lt;P&gt;I'm putting this example for future users. The answer you've marked as correct cannot be correct given what you've stated that the variable is character, so most likely there's something else going on that you haven't stated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the sample code below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*create sample data with format described by OP, date as character in format YYYY-MM-DD and a SAS date variable;
data sample;
do date='01Jan2017'd to '31Dec2017'd;
date_char = put(date, yymmdd10.);
output;
end;
run;

proc sql;
*Correct answer according to OP;
create table wrong as
select * 
from sample
where date_char &amp;lt; '01JUL2017';

*Comparison with date variables;
create table correct1 as
select *
from sample
where date &amp;lt; '01JUL2017'd;

create table correct2 as
select *
from sample
where input(date_char, yymmdd10.) &amp;lt; '01JUL2017'd;

quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388894#M65983</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-17T17:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Date format from yyyy-mm-dd to yyyymmdd</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388917#M65987</link>
      <description>&lt;P&gt;Thank you again,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;. You've been very helpful.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-format-from-yyyy-mm-dd-to-yyyymmdd/m-p/388917#M65987</guid>
      <dc:creator>serrld113</dc:creator>
      <dc:date>2017-08-17T17:58:29Z</dc:date>
    </item>
  </channel>
</rss>

