<?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: how to convert character date to yymmdd8 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-convert-character-date-to-yymmdd8/m-p/51782#M14242</link>
    <description>Hi:&lt;BR /&gt;
  In this instance, it would be useful to see your WHOLE program log and messages. I doubt that the '.' is what's generating the error message. I can use your same data in a program and yyddmm8. and do not get an error message.&lt;BR /&gt;
 &lt;BR /&gt;
  There is a difference between the INFORMAT that you use to read in a date value and the FORMAT that you use to display a date value. The yymmdd8. is the correct format for reading in the date, since there are no delimiters in the date, it is translated from a character value to a numeric number of days since Jan 1, 1960.&lt;BR /&gt;
&lt;BR /&gt;
  The display of your date field is different however, yymmdd FORMAT (versus INFORMAT) wants there to be separators in a DISPLAYED date. so a FORMAT of yymmdd8. will result in the display you showed.&lt;BR /&gt;
 &lt;BR /&gt;
  Here's the program I ran and the results are at the very bottom of the mail. Note the difference between the different PUT statements in the log. Each PUT statement uses a different FORMAT -- with the first PUT statement showing the internal value of the variables. Compare the results of the YYMMDD8. format with the YYMMDDN8. format -- the 'N' in the format name tells SAS not to use any separators for the date when the date is DISPLAYED.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data chardate;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input date $;&lt;BR /&gt;
  newdate = input(date,yymmdd8.);&lt;BR /&gt;
  put '***************************************';&lt;BR /&gt;
  put 'newdate is (internal value): ' newdate;&lt;BR /&gt;
  put 'newdate formatted 1: ' newdate date7.;&lt;BR /&gt;
  put 'newdate formatted 2: ' newdate yymmdd8.;&lt;BR /&gt;
  put 'newdate formatted 3: ' newdate yymmdd10.;&lt;BR /&gt;
  put 'newdate formatted 4: ' newdate yymmddn8.;&lt;BR /&gt;
  put 'newdate formatted 5: ' newdate worddate.;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
20071206&lt;BR /&gt;
20011102&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
            &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
The entire  SAS log:&lt;BR /&gt;
[pre]&lt;BR /&gt;
296  data chardate;&lt;BR /&gt;
297    infile datalines;&lt;BR /&gt;
298    input date $;&lt;BR /&gt;
299    newdate = input(date,yymmdd8.);&lt;BR /&gt;
300    put '***************************************';&lt;BR /&gt;
301    put 'newdate is (internal value): ' newdate;&lt;BR /&gt;
302    put 'newdate formatted 1: ' newdate date7.;&lt;BR /&gt;
303    put 'newdate formatted 2: ' newdate yymmdd8.;&lt;BR /&gt;
304    put 'newdate formatted 3: ' newdate yymmdd10.;&lt;BR /&gt;
305    put 'newdate formatted 4: ' newdate yymmddn8.;&lt;BR /&gt;
306    put 'newdate formatted 5: ' newdate worddate.;&lt;BR /&gt;
307  return;&lt;BR /&gt;
308  datalines;&lt;BR /&gt;
&lt;BR /&gt;
***************************************&lt;BR /&gt;
newdate is (internal value): 17506&lt;BR /&gt;
newdate formatted 1: 06DEC07&lt;BR /&gt;
newdate formatted 2: 07-12-06&lt;BR /&gt;
newdate formatted 3: 2007-12-06&lt;BR /&gt;
newdate formatted 4: 20071206&lt;BR /&gt;
newdate formatted 5:   December 6, 2007&lt;BR /&gt;
***************************************&lt;BR /&gt;
newdate is (internal value): 15281&lt;BR /&gt;
newdate formatted 1: 02NOV01&lt;BR /&gt;
newdate formatted 2: 01-11-02&lt;BR /&gt;
newdate formatted 3: 2001-11-02&lt;BR /&gt;
newdate formatted 4: 20011102&lt;BR /&gt;
newdate formatted 5:   November 2, 2001&lt;BR /&gt;
NOTE: The data set WORK.CHARDATE has 2 observations and 2 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.43 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
311  ;&lt;BR /&gt;
312  run;&lt;BR /&gt;
               &lt;BR /&gt;
[/pre]</description>
    <pubDate>Sat, 17 Jul 2010 13:29:29 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-07-17T13:29:29Z</dc:date>
    <item>
      <title>how to convert character date to yymmdd8</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-convert-character-date-to-yymmdd8/m-p/51779#M14239</link>
      <description>Hi,&lt;BR /&gt;
my input file has the following data:&lt;BR /&gt;
&lt;BR /&gt;
date$&lt;BR /&gt;
20071206&lt;BR /&gt;
20011102&lt;BR /&gt;
&lt;BR /&gt;
20071009&lt;BR /&gt;
i use the following:&lt;BR /&gt;
dt=input(date,yymmdd8.);&lt;BR /&gt;
but my output looks like&lt;BR /&gt;
&lt;BR /&gt;
07-12-06&lt;BR /&gt;
01-11-02&lt;BR /&gt;
.&lt;BR /&gt;
07-10-09&lt;BR /&gt;
because of the "." i can getting error invlaid argument used in input statement.&lt;BR /&gt;
&lt;BR /&gt;
can anybody tell me how can i do this.&lt;BR /&gt;
&lt;BR /&gt;
thanks</description>
      <pubDate>Sat, 17 Jul 2010 02:17:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-convert-character-date-to-yymmdd8/m-p/51779#M14239</guid>
      <dc:creator>ren2010</dc:creator>
      <dc:date>2010-07-17T02:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert character date to yymmdd8</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-convert-character-date-to-yymmdd8/m-p/51780#M14240</link>
      <description>You will want to use a SAS FORMAT statement or an ATTRIB stmt FMT= parameter to define a desirable SAS numeric DATE format to suit your needs.  You must have a format being associated by default.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sat, 17 Jul 2010 02:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-convert-character-date-to-yymmdd8/m-p/51780#M14240</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-07-17T02:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert character date to yymmdd8</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-convert-character-date-to-yymmdd8/m-p/51781#M14241</link>
      <description>Hi. I think 'yymmddn8' should be useful.&lt;BR /&gt;
[pre]&lt;BR /&gt;
dt=input(date,yymmdd8.);&lt;BR /&gt;
format dt yymmddn8.;&lt;BR /&gt;
put dt=;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Sat, 17 Jul 2010 10:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-convert-character-date-to-yymmdd8/m-p/51781#M14241</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-07-17T10:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert character date to yymmdd8</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-convert-character-date-to-yymmdd8/m-p/51782#M14242</link>
      <description>Hi:&lt;BR /&gt;
  In this instance, it would be useful to see your WHOLE program log and messages. I doubt that the '.' is what's generating the error message. I can use your same data in a program and yyddmm8. and do not get an error message.&lt;BR /&gt;
 &lt;BR /&gt;
  There is a difference between the INFORMAT that you use to read in a date value and the FORMAT that you use to display a date value. The yymmdd8. is the correct format for reading in the date, since there are no delimiters in the date, it is translated from a character value to a numeric number of days since Jan 1, 1960.&lt;BR /&gt;
&lt;BR /&gt;
  The display of your date field is different however, yymmdd FORMAT (versus INFORMAT) wants there to be separators in a DISPLAYED date. so a FORMAT of yymmdd8. will result in the display you showed.&lt;BR /&gt;
 &lt;BR /&gt;
  Here's the program I ran and the results are at the very bottom of the mail. Note the difference between the different PUT statements in the log. Each PUT statement uses a different FORMAT -- with the first PUT statement showing the internal value of the variables. Compare the results of the YYMMDD8. format with the YYMMDDN8. format -- the 'N' in the format name tells SAS not to use any separators for the date when the date is DISPLAYED.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data chardate;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input date $;&lt;BR /&gt;
  newdate = input(date,yymmdd8.);&lt;BR /&gt;
  put '***************************************';&lt;BR /&gt;
  put 'newdate is (internal value): ' newdate;&lt;BR /&gt;
  put 'newdate formatted 1: ' newdate date7.;&lt;BR /&gt;
  put 'newdate formatted 2: ' newdate yymmdd8.;&lt;BR /&gt;
  put 'newdate formatted 3: ' newdate yymmdd10.;&lt;BR /&gt;
  put 'newdate formatted 4: ' newdate yymmddn8.;&lt;BR /&gt;
  put 'newdate formatted 5: ' newdate worddate.;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
20071206&lt;BR /&gt;
20011102&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
            &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
The entire  SAS log:&lt;BR /&gt;
[pre]&lt;BR /&gt;
296  data chardate;&lt;BR /&gt;
297    infile datalines;&lt;BR /&gt;
298    input date $;&lt;BR /&gt;
299    newdate = input(date,yymmdd8.);&lt;BR /&gt;
300    put '***************************************';&lt;BR /&gt;
301    put 'newdate is (internal value): ' newdate;&lt;BR /&gt;
302    put 'newdate formatted 1: ' newdate date7.;&lt;BR /&gt;
303    put 'newdate formatted 2: ' newdate yymmdd8.;&lt;BR /&gt;
304    put 'newdate formatted 3: ' newdate yymmdd10.;&lt;BR /&gt;
305    put 'newdate formatted 4: ' newdate yymmddn8.;&lt;BR /&gt;
306    put 'newdate formatted 5: ' newdate worddate.;&lt;BR /&gt;
307  return;&lt;BR /&gt;
308  datalines;&lt;BR /&gt;
&lt;BR /&gt;
***************************************&lt;BR /&gt;
newdate is (internal value): 17506&lt;BR /&gt;
newdate formatted 1: 06DEC07&lt;BR /&gt;
newdate formatted 2: 07-12-06&lt;BR /&gt;
newdate formatted 3: 2007-12-06&lt;BR /&gt;
newdate formatted 4: 20071206&lt;BR /&gt;
newdate formatted 5:   December 6, 2007&lt;BR /&gt;
***************************************&lt;BR /&gt;
newdate is (internal value): 15281&lt;BR /&gt;
newdate formatted 1: 02NOV01&lt;BR /&gt;
newdate formatted 2: 01-11-02&lt;BR /&gt;
newdate formatted 3: 2001-11-02&lt;BR /&gt;
newdate formatted 4: 20011102&lt;BR /&gt;
newdate formatted 5:   November 2, 2001&lt;BR /&gt;
NOTE: The data set WORK.CHARDATE has 2 observations and 2 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.43 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
311  ;&lt;BR /&gt;
312  run;&lt;BR /&gt;
               &lt;BR /&gt;
[/pre]</description>
      <pubDate>Sat, 17 Jul 2010 13:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-convert-character-date-to-yymmdd8/m-p/51782#M14242</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-07-17T13:29:29Z</dc:date>
    </item>
  </channel>
</rss>

