<?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: Character date into date format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831854#M328785</link>
    <description>Thanks I will have a go in the morning and let you know how I get on. Cheers&lt;BR /&gt;</description>
    <pubDate>Mon, 05 Sep 2022 18:21:30 GMT</pubDate>
    <dc:creator>Billy1979</dc:creator>
    <dc:date>2022-09-05T18:21:30Z</dc:date>
    <item>
      <title>Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831820#M328769</link>
      <description>&lt;P&gt;I have character dates and converting them to num date9. but fails to work for char date which is like "20060614".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dates are formatted&amp;nbsp;&lt;/P&gt;&lt;P&gt;20060614&lt;BR /&gt;20060531&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im trying to get the format in to date format -&lt;/P&gt;&lt;P&gt;14JUN2006&lt;/P&gt;&lt;P&gt;i use the below step and it works for first record but doesnt work for second one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have tried a number of different ways - search quite a few different site but no go.&lt;/P&gt;&lt;P&gt;below is one of the examples i have tired.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data.work.temp;&lt;/P&gt;&lt;P&gt;set.despatch;&lt;/P&gt;&lt;P&gt;date=input(date_of_despatch, yymmdd10.);&lt;/P&gt;&lt;P&gt;format date date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but not getting any joy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any help would be much appreciated. thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 15:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831820#M328769</guid>
      <dc:creator>Billy1979</dc:creator>
      <dc:date>2022-09-05T15:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831831#M328774</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    want_date=input(put(date,8.),yymmdd10.);
    format want_date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes your original dates are numeric, although you haven't actually said that. &lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 16:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831831#M328774</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-05T16:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831838#M328779</link>
      <description>&lt;P&gt;The code works with the values you showed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input date_of_despatch $char10.;
cards;
20060614
20060531
;

data want;
  set have;
  date=input(date_of_despatch, yymmdd10.);
  format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Perhaps the values are not what you think they are.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some that do not work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input date_of_despatch $char20.;
  if _n_=4 then date_of_despatch=cats(date_of_despatch,'0D'x);
  if _n_=5 then date_of_despatch=cats('09'x,date_of_despatch);
cards;
20060531
2006O531
   20060531
20060531
20060531
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;3966   data want;
3967     set have;
3968     date=input(date_of_despatch, yymmdd10.);
3969     format date date9.;
3970   run;

NOTE: Invalid argument to function INPUT at line 3968 column 8.
date_of_despatch=2006O531 date=. _ERROR_=1 _N_=2
NOTE: Invalid argument to function INPUT at line 3968 column 8.
date_of_despatch=20060531 date=. _ERROR_=1 _N_=3
NOTE: Invalid argument to function INPUT at line 3968 column 8.
date_of_despatch=20060531
 date=. _ERROR_=1 _N_=4
NOTE: Invalid argument to function INPUT at line 3968 column 8.
date_of_despatch=	20060531 date=. _ERROR_=1 _N_=5
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
      missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      4 at 3968:8
NOTE: The data set WORK.WANT has 5 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Sep 2022 17:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831838#M328779</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-05T17:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831853#M328784</link>
      <description>Thanks Tom,&lt;BR /&gt;&lt;BR /&gt;I will have a go in the morning and let you know how I get my on.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Sep 2022 18:19:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831853#M328784</guid>
      <dc:creator>Billy1979</dc:creator>
      <dc:date>2022-09-05T18:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831854#M328785</link>
      <description>Thanks I will have a go in the morning and let you know how I get on. Cheers&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Sep 2022 18:21:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831854#M328785</guid>
      <dc:creator>Billy1979</dc:creator>
      <dc:date>2022-09-05T18:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831884#M328790</link>
      <description>&lt;P&gt;so the original field is character field. i need to convert it to numeric date field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i hope that make sense&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 08:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831884#M328790</guid>
      <dc:creator>Billy1979</dc:creator>
      <dc:date>2022-09-06T08:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831892#M328794</link>
      <description>&lt;P&gt;so the original field is character field. i need to convert it to numeric date field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;so looking at the columns&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Name&lt;/STRONG&gt; Date_of_despatch&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Type&lt;/STRONG&gt; Character&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;length&lt;/STRONG&gt; 8&lt;/P&gt;&lt;P&gt;data in the field - 20060614&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i hope that make sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i have done the below,&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;date=input(date_of_despatch, yymmdd10.);&lt;BR /&gt;format date date9.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I run it I'm getting back blank fields -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 09:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831892#M328794</guid>
      <dc:creator>Billy1979</dc:creator>
      <dc:date>2022-09-06T09:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831895#M328796</link>
      <description>&lt;P&gt;Works for me, I'm not getting blank output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    date_of_despatch='20060614';
run;
data want;
    set have;
    date=input(date_of_despatch, yymmdd10.);
    format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us the &lt;FONT color="#FF0000"&gt;ENTIRE&lt;/FONT&gt; LOG from your code. Copy the log as text and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 10:06:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831895#M328796</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-06T10:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831897#M328798</link>
      <description>&lt;PRE&gt;NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
22         
23         GOPTIONS ACCESSIBLE;
24         data want;
25          set atwd.atwd_despatches;;
26          date=input(date_of_despatch_of_good, yymmdd10.);
27          format date date9.;
28          run;



NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
      26:13   
NOTE: Variable date_of_despatch_of_good is uninitialized.
NOTE: There were 558694 observations read from the data set ATWD.ATWD_DESPATCHES.
NOTE: MVA_DSIO.OPEN_CLOSE| _DISARM|         STOP| _DISARM| 2022-09-06T11:31:26,527+01:00| _DISARM| WorkspaceServer| _DISARM| SAS|
      _DISARM| | _DISARM| 558694| _DISARM| 28483584| _DISARM| 12| _DISARM| 21| _DISARM| 178712| _DISARM| 23761272| _DISARM|
      1.510000| _DISARM| 1.501806| _DISARM| 1978079485.025541| _DISARM| 1978079486.527347| _DISARM| 0.890000| _DISARM| | _ENDDISARM
NOTE: The data set WORK.WANT has 558694 observations and 17 variables.
NOTE: Compressing data set WORK.WANT decreased size by 80.98 percent.
      Compressed is 1398 pages; un-compressed would require 7352 pages.
NOTE: MVA_DSIO.OPEN_CLOSE| _DISARM|         STOP| _DISARM| 2022-09-06T11:31:26,567+01:00| _DISARM| WorkspaceServer| _DISARM| SAS|
      _DISARM| | _DISARM| 558694| _DISARM| 28483584| _DISARM| 12| _DISARM| 21| _DISARM| 178968| _DISARM| 23761536| _DISARM|
      1.520000| _DISARM| 1.537450| _DISARM| 1978079485.030051| _DISARM| 1978079486.567501| _DISARM| 0.880000| _DISARM| | _ENDDISARM
NOTE: PROCEDURE| _DISARM|         STOP| _DISARM| 2022-09-06T11:31:26,567+01:00| _DISARM| WorkspaceServer| _DISARM| SAS| _DISARM| |
      _DISARM| 1104273408| _DISARM| 28483584| _DISARM| 12| _DISARM| 21| _DISARM| 178976| _DISARM| 23761536| _DISARM| 1.530000|
      _DISARM| 1.551203| _DISARM| 1978079485.016803| _DISARM| 1978079486.568006| _DISARM| 0.890000| _DISARM| | _ENDDISARM
NOTE: DATA statement used (Total process time):
      real time           1.55 seconds
      cpu time            1.53 seconds
      



29         
30         GOPTIONS NOACCESSIBLE;
31         %LET _CLIENTTASKLABEL=;
32         %LET _CLIENTPROCESSFLOWNAME=;
33         %LET _CLIENTPROJECTPATH=;
34         %LET _CLIENTPROJECTNAME=;
2                                                          The SAS System                           09:28 Tuesday, September 6, 2022



35         %LET _SASPROGRAMFILE=;
36         
37         ;*';*";*/;quit;run;
38         ODS _ALL_ CLOSE;
39         
40         
41         QUIT; RUN;
42  &lt;/PRE&gt;&lt;P&gt;the example you posted&amp;nbsp;&lt;SPAN&gt;Paige worked fine.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but when I try and use it on the dataset it just returns blanks. I have attached the log. thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 10:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831897#M328798</guid>
      <dc:creator>Billy1979</dc:creator>
      <dc:date>2022-09-06T10:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831900#M328801</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Variable date_of_despatch_of_good is uninitialized.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This variable does not exist in your input data set&amp;nbsp;atwd.atwd_despatches&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 11:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831900#M328801</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-06T11:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831907#M328807</link>
      <description>&lt;P&gt;You NEVER want to see such a message in the log:&lt;/P&gt;
&lt;PRE&gt;NOTE: Variable date_of_despatch_of_good is uninitialized.
&lt;/PRE&gt;
&lt;P&gt;This is one of the NOTEs that causes a log to be "dirty", see Maxim 25.&lt;/P&gt;
&lt;P&gt;This NOTE means you typed the variable name incorrectly, or used the wrong dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS in an earlier message you wrote&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;so the original field is character field. i need to convert it to numeric date field.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so looking at the columns&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Name&lt;/STRONG&gt; Date_of_despatch&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Type&lt;/STRONG&gt; Character&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;length&lt;/STRONG&gt; 8&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;so you most probably mistyped the variable name.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 12:09:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831907#M328807</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-09-06T12:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Character date into date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831910#M328809</link>
      <description>&lt;P&gt;Thanks Guys&lt;/P&gt;&lt;P&gt;should of double checked the fields properly.&lt;/P&gt;&lt;P&gt;thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 12:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-into-date-format/m-p/831910#M328809</guid>
      <dc:creator>Billy1979</dc:creator>
      <dc:date>2022-09-06T12:17:37Z</dc:date>
    </item>
  </channel>
</rss>

