<?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: Converting Character date to sas date in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637884#M21497</link>
    <description>&lt;P&gt;Thanks everyone for all of the assistance. I will try all of the suggested changes tomorrow and revert.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you, everyone.&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Apr 2020 16:03:27 GMT</pubDate>
    <dc:creator>MagD</dc:creator>
    <dc:date>2020-04-06T16:03:27Z</dc:date>
    <item>
      <title>Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637854#M21486</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope everyone is keeping safe during these uncertain and difficult times of global pandemic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please assist me with some coding regarding dates. I am trying to change this date 2020-04-06 (character) to ''06Apr2020'' in sas. Please assist me.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 14:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637854#M21486</guid>
      <dc:creator>MagD</dc:creator>
      <dc:date>2020-04-06T14:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637857#M21487</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sas_date = input(character_date, yymmdd10.);
format sas_date yymmdd10.;&lt;BR /&gt;*format&amp;nbsp;sas_date&amp;nbsp;date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;INPUT() converts the variable to a SAS date&lt;/P&gt;
&lt;P&gt;FORMAT controls the appearance of the date, try un-commenting the third line to see the difference.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289428"&gt;@MagD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope everyone is keeping safe during these uncertain and difficult times of global pandemic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please assist me with some coding regarding dates. I am trying to change this date 2020-04-06 (character) to ''06Apr2020'' in sas. Please assist me.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 14:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637857#M21487</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-06T14:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637858#M21488</link>
      <description>&lt;P&gt;You can use INPUT() function (or INPUTN or INPUTC) to convert TEXT into VALUES.&amp;nbsp; The INFORMAT for converting strings like that is YYMMDD.&amp;nbsp; Once you have a date value you can attach the DATE format to have it displayed as text in the style you mentioned.&lt;/P&gt;
&lt;P&gt;So if your source dataset is named HAVE and the strings are in the variable named CHAR then this data step will make a new dataset named WANT with a new numeric variable named NUM with the converted date values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  num = input(char,yymmdd10.);
  format num date9. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Apr 2020 14:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637858#M21488</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-06T14:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637860#M21489</link>
      <description>Hi Reeza,&lt;BR /&gt;&lt;BR /&gt;I've used your recommended solution but I am getting the following error:&lt;BR /&gt;''Format $DATE was not found or could not be loaded''. This error is applicable to the date9.</description>
      <pubDate>Mon, 06 Apr 2020 15:01:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637860#M21489</guid>
      <dc:creator>MagD</dc:creator>
      <dc:date>2020-04-06T15:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637861#M21490</link>
      <description>&lt;P&gt;There is no $ before DATE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us your code. Error messages by themselves without seeing the code are not particularly useful.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 15:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637861#M21490</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-06T15:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637862#M21491</link>
      <description>You cannot attach a numeric format, DATE, to a character variable.  When you do that SAS tries help fix your mistake by assuming you meant to use a character format.  But it cannot find any format named $DATE.  Make sure that the variable you are creating to store the date values is numeric.&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Apr 2020 15:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637862#M21491</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-06T15:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637866#M21492</link>
      <description>Did you change the variable name or try and use the same variable name? You cannot keep the same variable name or need to rename it. &lt;BR /&gt;&lt;BR /&gt;Show your code.</description>
      <pubDate>Mon, 06 Apr 2020 15:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637866#M21492</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-06T15:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637869#M21493</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my code:&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set invoices;&lt;BR /&gt;invoice_date = input(character_date, yymmdd10.);&lt;BR /&gt;format invoice_date date9.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The invoice_date variable is the variable that I am trying to change from 2020-03-03 to 03MAR2020 but I am getting the following error:&lt;/P&gt;
&lt;P&gt;Format $date9. was not found or could not be loaded.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 15:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637869#M21493</guid>
      <dc:creator>MagD</dc:creator>
      <dc:date>2020-04-06T15:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637871#M21494</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289428"&gt;@MagD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my code:&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set invoices;&lt;BR /&gt;invoice_date = input(character_date, yymmdd10.);&lt;BR /&gt;format invoice_date date9.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The invoice_date variable is the variable that I am trying to change from 2020-03-03 to 03MAR2020 but I am getting the following error:&lt;/P&gt;
&lt;P&gt;Format $date9. was not found or could not be loaded.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your comment makes it sound like INVOICE_DATE is the existing character variable. Your code is trying to create a NEW variable named INVOICE_DATE from an existing character variable named CHARACTER_DATE.&amp;nbsp; The error message is basically saying that INVOICE_DATE already existed and is a CHARACTER variable.&amp;nbsp; You also should have had notes about SAS converting the numeric values that the INPUT() function generate to text when it tried to store the results into the character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to create a numeric date variable or not?&amp;nbsp; What name do you want this new variable to have?&amp;nbsp; Perhaps you just need to add a RENAME= dataset option on the reference to INVOICES in the SET statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set invoices(rename=(invoice_date=character_date));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Apr 2020 15:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637871#M21494</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-06T15:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637879#M21495</link>
      <description>&lt;P&gt;If you just want leave it as a character variable but change how the dates are represented as character strings then add a PUT() function call to the assignment statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;invoice_date = put(input(invoice_date , yymmdd10.),date9.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Apr 2020 15:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637879#M21495</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-06T15:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637884#M21497</link>
      <description>&lt;P&gt;Thanks everyone for all of the assistance. I will try all of the suggested changes tomorrow and revert.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you, everyone.&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 16:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/637884#M21497</guid>
      <dc:creator>MagD</dc:creator>
      <dc:date>2020-04-06T16:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Character date to sas date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/640619#M21750</link>
      <description>&lt;P&gt;I used this code as the solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;data fix_date;&lt;BR /&gt;set ECOM.Invoiced_Apps;&lt;BR /&gt;format Inv_Date date9.;&lt;BR /&gt;Inv_Date = mdy(substr(Invoice_Date,6,2),substr(Invoice_Date,9,2),substr(Invoice_Date,1,4));&lt;BR /&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Thank you all for all of your assistance with this query.&lt;/DIV&gt;</description>
      <pubDate>Fri, 17 Apr 2020 07:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-Character-date-to-sas-date/m-p/640619#M21750</guid>
      <dc:creator>MagD</dc:creator>
      <dc:date>2020-04-17T07:05:12Z</dc:date>
    </item>
  </channel>
</rss>

