<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627120#M185041</link>
    <description>Hi KurtBremser&lt;BR /&gt;Thanks for the quick response&lt;BR /&gt;ys sure i will give the example plz find below&lt;BR /&gt;{&lt;BR /&gt;first the hdrdate = 20200120 it's in ccyymmdd format&lt;BR /&gt;and it updated fine in table&lt;BR /&gt;then i have given hdrdate = 20200140 for testing&lt;BR /&gt;above date also updated&lt;BR /&gt;my question is how come it updated a month have only 31 days it went beyond 31 days right&lt;BR /&gt;how to put a checkpoint on the above issue&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Rohitkrishna</description>
    <pubDate>Tue, 25 Feb 2020 08:02:45 GMT</pubDate>
    <dc:creator>rohitkrishna</dc:creator>
    <dc:date>2020-02-25T08:02:45Z</dc:date>
    <item>
      <title>date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627114#M185035</link>
      <description>&lt;P&gt;Hi team,&lt;/P&gt;&lt;P&gt;I had one regarding the date format checkpoint&lt;/P&gt;&lt;P&gt;the question is&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if the hdrdate is 20200120&lt;/P&gt;&lt;P&gt;it updated fine in the table but I was given instead of 20 I have given 40 in the dd I mean to date it accepted that one how come it happens I don't know bez a month date has ending with the 31 only right&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i requesting you give some solution above problem how to put a checkpoint on the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rohitkrishna&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 07:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627114#M185035</guid>
      <dc:creator>rohitkrishna</dc:creator>
      <dc:date>2020-02-25T07:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627116#M185037</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259823"&gt;@rohitkrishna&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi team,&lt;/P&gt;
&lt;P&gt;I had one regarding the date format checkpoint&lt;/P&gt;
&lt;P&gt;the question is&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if the hdrdate is 20200120&lt;/P&gt;
&lt;P&gt;it updated fine in the table but I was given instead of 20 I have given 40 in the dd I mean to date it accepted that one how come it happens I don't know bez a month date has ending with the 31 only right&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so i requesting you give some solution above problem how to put a checkpoint on the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rohitkrishna&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sorry, I can't make sense of this.&lt;/P&gt;
&lt;P&gt;Please supply example data, code and logs that illustrate your issue.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 07:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627116#M185037</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-25T07:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627120#M185041</link>
      <description>Hi KurtBremser&lt;BR /&gt;Thanks for the quick response&lt;BR /&gt;ys sure i will give the example plz find below&lt;BR /&gt;{&lt;BR /&gt;first the hdrdate = 20200120 it's in ccyymmdd format&lt;BR /&gt;and it updated fine in table&lt;BR /&gt;then i have given hdrdate = 20200140 for testing&lt;BR /&gt;above date also updated&lt;BR /&gt;my question is how come it updated a month have only 31 days it went beyond 31 days right&lt;BR /&gt;how to put a checkpoint on the above issue&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Rohitkrishna</description>
      <pubDate>Tue, 25 Feb 2020 08:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627120#M185041</guid>
      <dc:creator>rohitkrishna</dc:creator>
      <dc:date>2020-02-25T08:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627122#M185043</link>
      <description>&lt;P&gt;&lt;STRONG&gt;DATASET&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;CODE&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;LOG&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;EXPECTED OUTPUT&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 08:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627122#M185043</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-25T08:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627139#M185054</link>
      <description>Hi KurtBremser&lt;BR /&gt;thanks for the response&lt;BR /&gt;ya sure&lt;BR /&gt;{&lt;BR /&gt;DATA DT_FT;&lt;BR /&gt;INFILE DATALINES;&lt;BR /&gt;INPUT @1 DATE $CHAR8.;&lt;BR /&gt;DATALINES;&lt;BR /&gt;20200120&lt;BR /&gt;20200140&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;BR /&gt;PROC PRINT DATA = DT_FT;&lt;BR /&gt;RUN;&lt;BR /&gt;output:&lt;BR /&gt;Obs DATE&lt;BR /&gt;&lt;BR /&gt;1 20200120&lt;BR /&gt;2 20200140&lt;BR /&gt;my ask is how the second date has been updated&lt;BR /&gt;it is greater than 31 right&lt;BR /&gt;so my expected output is&lt;BR /&gt;{&lt;BR /&gt;20200120 it printing fine&lt;BR /&gt;but second, has to print error&lt;BR /&gt;bez it is greater than 31&lt;BR /&gt;}&lt;BR /&gt;plz kindly give some solution for the above issue&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Rohit&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Feb 2020 09:54:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627139#M185054</guid>
      <dc:creator>rohitkrishna</dc:creator>
      <dc:date>2020-02-25T09:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627140#M185055</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259823"&gt;@rohitkrishna&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what if you read the data directly as a SAS date using the YYMMDD10. informat?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA DT_FT;
INFILE DATALINES;
INPUT @1 DATE:YYMMDD10.;
FORMAT DATE:YYMMDD10.;
DATALINES;
20200120
20200140
;
RUN;

PROC PRINT DATA = DT_FT;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 09:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627140#M185055</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-25T09:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627142#M185057</link>
      <description>Hi ed_sas_member,&lt;BR /&gt;Thanks for the response it's working fine but my requirement is how to put a check point to stop the displaying the 20200140&lt;BR /&gt;and moreover, my expected output is&lt;BR /&gt;20200120&lt;BR /&gt;not 2020-01-20&lt;BR /&gt;i tried to give yymmdd8. but it shows&lt;BR /&gt;Obs DATE&lt;BR /&gt;&lt;BR /&gt;1 20-01-20&lt;BR /&gt;2 .&lt;BR /&gt;above one i got&lt;BR /&gt;so plz kindly respond on the above issue&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Rohit&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Feb 2020 10:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627142#M185057</guid>
      <dc:creator>rohitkrishna</dc:creator>
      <dc:date>2020-02-25T10:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627143#M185058</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259823"&gt;@rohitkrishna&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA DT_FT;
INFILE DATALINES;
INPUT @1 DATE $CHAR8.;
length check $ 20;
IF input(DATE,YYMMDD10.) ne . then check=Date;
else check = "not valid: "||date;
DATALINES;
20200120
20200140
;
RUN;

PROC PRINT DATA = DT_FT;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Feb 2020 10:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627143#M185058</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-25T10:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627146#M185059</link>
      <description>Hi ed_sas_member&lt;BR /&gt;Thanks for the quick response&lt;BR /&gt;ya it's superb it's working fine&lt;BR /&gt;But my small request is&lt;BR /&gt;if the date is less then that it displays not valid&lt;BR /&gt;like&lt;BR /&gt;date &amp;lt; 31 display not valid&lt;BR /&gt;above condition possible kindly gives some suggestions&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Rohit</description>
      <pubDate>Tue, 25 Feb 2020 10:45:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627146#M185059</guid>
      <dc:creator>rohitkrishna</dc:creator>
      <dc:date>2020-02-25T10:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627148#M185060</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259823"&gt;@rohitkrishna&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a slight change:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA DT_FT;
INFILE DATALINES;
INPUT @1 DATE $CHAR8.;
length check $ 20;
IF 0 &amp;lt; day(input(DATE,YYMMDD10.)) &amp;lt;= 31 then check=Date;
else check = "not valid: "||date;
DATALINES;
20200120
20200140
;
RUN;

PROC PRINT DATA = DT_FT;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Feb 2020 10:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627148#M185060</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-25T10:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627159#M185064</link>
      <description>Hi ed_sas_member&lt;BR /&gt;Thank you very much it's working&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Rohit</description>
      <pubDate>Tue, 25 Feb 2020 12:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627159#M185064</guid>
      <dc:creator>rohitkrishna</dc:creator>
      <dc:date>2020-02-25T12:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627166#M185069</link>
      <description>Thank you @rohitkhrishna!&lt;BR /&gt;Could you please accept the solution to mark the topic as answered?</description>
      <pubDate>Tue, 25 Feb 2020 12:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627166#M185069</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-25T12:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627235#M185097</link>
      <description>&lt;P&gt;Because your field is CHAR8 it accepts anything that fits that structure.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you'd like to have a date and verify it's a valid date, make the column a numeric type with a date format applied. Then if you try to insert an invalid date it will throw an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA DT_FT;
INFILE DATALINES;
informat date yymmdd8.;
format date date9.;
INPUT @1 DATE ;
DATALINES;
20200120
20200140
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259823"&gt;@rohitkrishna&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi KurtBremser&lt;BR /&gt;thanks for the response&lt;BR /&gt;ya sure&lt;BR /&gt;{&lt;BR /&gt;DATA DT_FT;&lt;BR /&gt;INFILE DATALINES;&lt;BR /&gt;INPUT @1 DATE $CHAR8.;&lt;BR /&gt;DATALINES;&lt;BR /&gt;20200120&lt;BR /&gt;20200140&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;BR /&gt;PROC PRINT DATA = DT_FT;&lt;BR /&gt;RUN;&lt;BR /&gt;output:&lt;BR /&gt;Obs DATE&lt;BR /&gt;&lt;BR /&gt;1 20200120&lt;BR /&gt;2 20200140&lt;BR /&gt;my ask is how the second date has been updated&lt;BR /&gt;it is greater than 31 right&lt;BR /&gt;so my expected output is&lt;BR /&gt;{&lt;BR /&gt;20200120 it printing fine&lt;BR /&gt;but second, has to print error&lt;BR /&gt;bez it is greater than 31&lt;BR /&gt;}&lt;BR /&gt;plz kindly give some solution for the above issue&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Rohit&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 16:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627235#M185097</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-25T16:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627242#M185100</link>
      <description>&lt;P&gt;It is very difficult to understand what you are actually asking for.&lt;/P&gt;
&lt;P&gt;It sounds like you have string of 8 digits and you want to use it to create a date. So use the INPUT() function with an appropriate INFORMAT will do that.&lt;/P&gt;
&lt;P&gt;But it also sounds like you want to add a business rule that if the number represented by the last two digits is invalid as a date then to use the last day of the month implied by the first 6 digits.&lt;/P&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   datevar=input(hdrdate,??yymmdd8.);
   if missing(datevar) and not missing(hdrdate) then do;
     datevar=input(hdrdate,??yymmn6.);
     if not missing(datevar) then datevar=intnx('month',datevar,0,'end');
  end;
  format datevar date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Feb 2020 17:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627242#M185100</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-25T17:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627426#M185221</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259823"&gt;@rohitkrishna&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;date &amp;lt; 31 display not valid&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And what about February, April, June??? Those months do not have a 31st at all.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 07:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format/m-p/627426#M185221</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-26T07:46:28Z</dc:date>
    </item>
  </channel>
</rss>

