<?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: Trouble Converting character data into date YYMMDD in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491106#M128709</link>
    <description>&lt;P&gt;Actually, if you want it to look &lt;EM&gt;exactly&lt;/EM&gt; the same, there needs to be a slight change to the format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format date_want yymmddd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as the standard yymmdd format will use slashes instead of dashes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now that's almost poetry. Slashes/dashes &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Aug 2018 06:39:06 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-08-30T06:39:06Z</dc:date>
    <item>
      <title>Trouble Converting character data into date YYMMDD</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491037#M128665</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm having a tough time converting a couple of character variable fields into date fields. Each of the variables listed below are in the format of "2017-01-31" in character format. I tried to manually convert it but it's not working. Each of the _new variables I created only removed the "-" sign but still have blank spaces in&amp;nbsp;them&amp;nbsp;despite including&amp;nbsp;the trim() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
	set raw;

	Opened_dt_new = trim(tranwrd(opened_dt, "-", ""));
	Maturity_dt_new = trim(tranwrd(maturity_dt, "-", ""));
	Fico_dt_new = trim(tranwrd(fico_dt, "-", ""));
	Expiration_dt_new = trim(tranwrd(expiration_dt, "-", ""));

	drop opened_dt maturity_dt Fico_dt expiration_dt;

	Opened_dt = input(Opened_dt_new, YYMMDD10.);
	format Opened_dt YYMMDD10.;
	Maturity_dt = input(Maturity_dt_new, YYMMDD10.);
	format Maturity_dt YYMMDD10.;
	Fico_dt = input(Fico_dt_new, YYMMDD10.);
	format Fico_dt YYMMDD10.;
	Expiration_dt = input(Expiration_dt_new, YYMMDD10.);
	format Expiration_dt YYMMDD10.;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Due to the fact that the _new variables have space in it, Format $YYMMDD was not found or could not be loaded. What is wrong here?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 00:15:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491037#M128665</guid>
      <dc:creator>Bankshot</dc:creator>
      <dc:date>2018-08-30T00:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Converting character data into date YYMMDD</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491038#M128666</link>
      <description>&lt;P&gt;For further clarification, after the using the&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;trim(tranwrd(opened_dt, "-", ""))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;method, the output looks like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;opened_dt&lt;/P&gt;
&lt;P&gt;2017 01 31;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where I'd like it to be:&lt;/P&gt;
&lt;P&gt;20170131;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 00:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491038#M128666</guid>
      <dc:creator>Bankshot</dc:creator>
      <dc:date>2018-08-30T00:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Converting character data into date YYMMDD</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491042#M128668</link>
      <description>&lt;P&gt;1. Use COMPRESS() to remove the - if you want&lt;/P&gt;
&lt;P&gt;2. You cannot convert and save back to the same name, it has to have a new name. Yes it's annoying but it's the rules for now. You can rename your old variables before and then assign them the old name in the conversion is a common work around.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. You do not need to remove the - ahead of time, you can use INPUT directly on it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what you need to do, note that it looks the exact same but you have different variable types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
date_have= '2017-01-31';

date_want = input(date_have, yymmdd10.);
format date_want yymmdd10.;


run;

*check your types and formats;
proc contents data=demo;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/41542"&gt;@Bankshot&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;I'm having a tough time converting a couple of character variable fields into date fields. Each of the variables listed below are in the format of "2017-01-31" in character format. I tried to manually convert it but it's not working. Each of the _new variables I created only removed the "-" sign but still have blank spaces in&amp;nbsp;them&amp;nbsp;despite including&amp;nbsp;the trim() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
	set raw;

	Opened_dt_new = trim(tranwrd(opened_dt, "-", ""));
	Maturity_dt_new = trim(tranwrd(maturity_dt, "-", ""));
	Fico_dt_new = trim(tranwrd(fico_dt, "-", ""));
	Expiration_dt_new = trim(tranwrd(expiration_dt, "-", ""));

	drop opened_dt maturity_dt Fico_dt expiration_dt;

	Opened_dt = input(Opened_dt_new, YYMMDD10.);
	format Opened_dt YYMMDD10.;
	Maturity_dt = input(Maturity_dt_new, YYMMDD10.);
	format Maturity_dt YYMMDD10.;
	Fico_dt = input(Fico_dt_new, YYMMDD10.);
	format Fico_dt YYMMDD10.;
	Expiration_dt = input(Expiration_dt_new, YYMMDD10.);
	format Expiration_dt YYMMDD10.;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Due to the fact that the _new variables have space in it, Format $YYMMDD was not found or could not be loaded. What is wrong here?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 00:36:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491042#M128668</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-30T00:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Converting character data into date YYMMDD</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491106#M128709</link>
      <description>&lt;P&gt;Actually, if you want it to look &lt;EM&gt;exactly&lt;/EM&gt; the same, there needs to be a slight change to the format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format date_want yymmddd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as the standard yymmdd format will use slashes instead of dashes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now that's almost poetry. Slashes/dashes &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 06:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491106#M128709</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-30T06:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Converting character data into date YYMMDD</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491344#M128834</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;Slashes/dashes" I like that. You should trademark that&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 17:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Converting-character-data-into-date-YYMMDD/m-p/491344#M128834</guid>
      <dc:creator>Bankshot</dc:creator>
      <dc:date>2018-08-30T17:07:10Z</dc:date>
    </item>
  </channel>
</rss>

