<?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 entered as 04/14/2021 as character to be converted to date as date number formatted: 2021-0 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785047#M250519</link>
    <description>&lt;P&gt;try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  datec='04/14/2021';
  date=input(datec,mmddyy10.);
  format date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Dec 2021 00:37:51 GMT</pubDate>
    <dc:creator>japelin</dc:creator>
    <dc:date>2021-12-09T00:37:51Z</dc:date>
    <item>
      <title>Date entered as 04/14/2021 as character to be converted to date as date number formatted: 2021-04-14</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785045#M250517</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;P&gt;Can someone let me know how to do this in a data step?&lt;/P&gt;
&lt;P&gt;Date entered as 04/14/2021 as character to be converted to date as date number formatted: 2021-04-14&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;blueblue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 00:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785045#M250517</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-12-09T00:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Date entered as 04/14/2021 as character to be converted to date as date number formatted: 2021-0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785047#M250519</link>
      <description>&lt;P&gt;try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  datec='04/14/2021';
  date=input(datec,mmddyy10.);
  format date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Dec 2021 00:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785047#M250519</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-12-09T00:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Date entered as 04/14/2021 as character to be converted to date as date number formatted: 2021-0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785051#M250520</link>
      <description>&lt;P&gt;May want the yymmddd10. to have the - character instead of slash, the third d is for dash in the yymmddx format.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 01:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785051#M250520</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-09T01:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Date entered as 04/14/2021 as character to be converted to date as date number formatted: 2021-0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785056#M250523</link>
      <description>&lt;P&gt;Let's assume you already have a dataset with a character variable with length of at least 10 bytes that contains strings like '04/14/2021'.&amp;nbsp; Let's make an example.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  string='04/14/2021';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now let's use that dataset to make a new dataset that also includes and actual date variable make from converting the string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  date = input(string,mmddyy10.);
  format date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;Obs      string            date

 1     04/14/2021    2021-04-14
&lt;/PRE&gt;
&lt;P&gt;Let's take a look at what we have.&lt;/P&gt;
&lt;PRE&gt;2792   data _null_;
2793    set want ;
2794    put string= $quote. / string= $hex20. /;
2795    put date= comma10. / date=date9. / date=yymmdd10. / date=mmddyy10. / date=ddmmyy10. / date = hex16. /;
2796   run;

string="04/14/2021"
string=30342F31342F32303231

date=22,384
date=14APR2021
date=2021-04-14
date=04/14/2021
date=14/04/2021
date=40D5DC0000000000
NOTE: There were 1 observations read from the data set WORK.WANT.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 02:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785056#M250523</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-09T02:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Date entered as 04/14/2021 as character to be converted to date as date number formatted: 2021-0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785304#M250603</link>
      <description>Hello,&lt;BR /&gt;Thanks for the response. &lt;BR /&gt;data want;&lt;BR /&gt;  set have;&lt;BR /&gt;  date = input(string,mmddyy10.);&lt;BR /&gt;  format date yymmdd10.;&lt;BR /&gt;run;&lt;BR /&gt;is mmddyy10. format of the string?&lt;BR /&gt;What if I want to have date as date and formatted such as 2021-04-14?&lt;BR /&gt;Regards,&lt;BR /&gt;blue blue&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Dec 2021 04:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785304#M250603</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-12-10T04:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Date entered as 04/14/2021 as character to be converted to date as date number formatted: 2021-0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785318#M250615</link>
      <description>&lt;P&gt;Maxim 4. Try It.&lt;/P&gt;
&lt;P&gt;Your code contains all the answers.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 07:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785318#M250615</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-10T07:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Date entered as 04/14/2021 as character to be converted to date as date number formatted: 2021-0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785465#M250672</link>
      <description>&lt;P&gt;In that code MMDDYY is an INFORMAT and YYMMDD is a FORMAT.&amp;nbsp; MMDDYY10. is the informat specification you are using with the INPUT() function. Since you set the width at 10 bytes it will only use the first 10 bytes of the character variable STRING.&amp;nbsp; YYMMDD10. is the format specification you are setting as the default way to display the values of DATE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the result is that DATE is a numeric value that has the number of days since start of 1960 and by default it will print as 10 characters with the first four being the YEAR number then a hyphen then two digits for the month number within that year another hyphen and then two digits for the day within that month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS you use a FORMAT to convert values into text.&amp;nbsp; You use an INFORMAT to convert text into values.&lt;/P&gt;
&lt;P&gt;You can use the INPUT statement to read text into values.&amp;nbsp; You can use the INPUT() function to convert text in a character string into a value.&lt;/P&gt;
&lt;P&gt;You can use the PUT statement to write values as text.&amp;nbsp; You can use the PUT() function to convert values into a character string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the FORMAT statement in a data step to permanently attach a particular format to a variable so that SAS will use that format when displaying the values by default.&amp;nbsp; Similarly you can use an INFORMAT statement to attach an informat that you want SAS to use by default when reading values into the variable via and INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:32:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-entered-as-04-14-2021-as-character-to-be-converted-to-date/m-p/785465#M250672</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-10T20:32:22Z</dc:date>
    </item>
  </channel>
</rss>

