<?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 Date Char to Numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582441#M165672</link>
    <description>&lt;P&gt;That's perhaps because you would have ran the below assignment statement too&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;chardate&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'01-18'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which you should not as your objective is to covert the value that you read from the input dataset, which I suppose you would have using a SET statement.&lt;/P&gt;</description>
    <pubDate>Tue, 20 Aug 2019 14:26:09 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-08-20T14:26:09Z</dc:date>
    <item>
      <title>Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582427#M165662</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a date variable in $5. format. I'm using the input function to convert it to monyy7. and I'm getting the following error message:&lt;/P&gt;&lt;P&gt;"Invalid argument to function INPUT at line..."&lt;/P&gt;&lt;P&gt;My current date values: ex:01-18&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;data need;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;format new_date monyy7.;&lt;/P&gt;&lt;P&gt;new_date = input (old_date, $5.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for you help!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 13:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582427#M165662</guid>
      <dc:creator>parmis</dc:creator>
      <dc:date>2019-08-20T13:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582428#M165663</link>
      <description>&lt;P&gt;what does&amp;nbsp;&lt;SPAN&gt;: ex:01-18&amp;nbsp; value represent in terms on date/month/year?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582428#M165663</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-20T14:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582429#M165664</link>
      <description>&lt;P&gt;So what does your character date look like? What date does 01-18 represent? The first of january 2018?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582429#M165664</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-20T14:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582431#M165665</link>
      <description>&lt;P&gt;Month-year, It's January 2018&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582431#M165665</guid>
      <dc:creator>parmis</dc:creator>
      <dc:date>2019-08-20T14:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582432#M165666</link>
      <description>&lt;P&gt;month and Year, It's January 2018&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:04:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582432#M165666</guid>
      <dc:creator>parmis</dc:creator>
      <dc:date>2019-08-20T14:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582433#M165667</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
date='01-18';
length _temp $4;
do _n_=2,1;
 _temp=cats(_temp,scan(date,_n_,'-'));
end;
want=input(_temp,yymmn4.);
format want monyy7.;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582433#M165667</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-20T14:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582434#M165668</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    chardate='01-18';
    date=input(chardate, anydtdte5.);
    format date monyy7.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582434#M165668</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-20T14:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582437#M165670</link>
      <description>&lt;P&gt;"01-18" was just&amp;nbsp;an example to show the format of the date. I do have other dates starting Jan 2018 to July 2019 (it's a monthly data).&lt;/P&gt;&lt;P&gt;when I submit the code you posted all my dates change to Jan 2018.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582437#M165670</guid>
      <dc:creator>parmis</dc:creator>
      <dc:date>2019-08-20T14:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582439#M165671</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183598"&gt;@parmis&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;"01-18" was just&amp;nbsp;an example to show the format of the date. I do have other dates starting Jan 2018 to July 2019 (it's a monthly data).&lt;/P&gt;
&lt;P&gt;when I submit the code you posted all my dates change to Jan 2018.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can you be specific and show us the exact code that results in "all my dates change to Jan 2018"? As far as I can tell, the code from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;works perfectly.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:20:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582439#M165671</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-20T14:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582441#M165672</link>
      <description>&lt;P&gt;That's perhaps because you would have ran the below assignment statement too&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;chardate&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'01-18'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which you should not as your objective is to covert the value that you read from the input dataset, which I suppose you would have using a SET statement.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582441#M165672</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-20T14:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582444#M165673</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;The following code works for all "01-18" dates but other dates like "02-18", "03-18"... becomes null in the new data set.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; need;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;current_date=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'01-18'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;new_date=input(current_date, &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;anydtdte5.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; new_date &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;monyy7.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582444#M165673</guid>
      <dc:creator>parmis</dc:creator>
      <dc:date>2019-08-20T14:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582446#M165674</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183598"&gt;@parmis&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;The following code works for all "01-18" dates but other dates like "02-18", "03-18"... becomes null in the new data set.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; need;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;current_date=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'01-18'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;new_date=input(current_date, &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;anydtdte5.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; new_date &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;monyy7.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Well, if you have the assignment statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;current_date='01-18';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then you are telling SAS to make current_date to be 01-18 for every record in data set HAVE. So SAS is doing exactly what you told it to do. Is that what you want? Is there a variable named CURRENT_DATE in data set HAVE?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582446#M165674</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-20T14:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582450#M165676</link>
      <description>&lt;P&gt;Warning: You are asking for trouble trying to store years in just two digits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your INPUT statement doesn't make any sense.&amp;nbsp; You are telling INPUT() to use the $ informat which means it generates a character value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To generate a DATE value use an INFORMAT that generates a date value.&amp;nbsp; It might be easiest given your MM-YY strings to just prefix it with '01-' so it looks like DD-MM-YY then you can use the DDMMYY informat to read that string into a DATE value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_date = input ('01-'||old_date, ddmmyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 16:01:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582450#M165676</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-20T16:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Date Char to Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582455#M165678</link>
      <description>&lt;P&gt;I guess it's the 18th of January in any given year. Or January 1st, 1918.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:52:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Date-Char-to-Numeric/m-p/582455#M165678</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-20T14:52:19Z</dc:date>
    </item>
  </channel>
</rss>

