<?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 to SAS Dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302722#M64224</link>
    <description>&lt;P&gt;data test;&lt;BR /&gt;format date yymmdd10.;&lt;BR /&gt;date = input('2016-01-01',yymmdd10.);run;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2016 17:02:33 GMT</pubDate>
    <dc:creator>nash_sas</dc:creator>
    <dc:date>2016-10-05T17:02:33Z</dc:date>
    <item>
      <title>Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302720#M64223</link>
      <description>&lt;P&gt;In serious need of help, struggling with date conversion. I am starting with a list of dates, let's call them start_date and end_date, and they are in the format (e.g. 2016/10/05) YY/MM/DD. I am struggling converting them into a numeric value so that I can then convert them into a SAS date then back into a character value. I have been online for hours looking for some type of explanation and code, but I have had no luck. I have even compressed the variable and taken out the '/', tried renaming it so I could keep original name then used the input statement but still not luck. Even tried using the put statement...please I am so stuck. I have been programming consistently for about a month now and this is my first encounter&amp;nbsp;with dates.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 16:54:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302720#M64223</guid>
      <dc:creator>trt3s</dc:creator>
      <dc:date>2016-10-05T16:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302722#M64224</link>
      <description>&lt;P&gt;data test;&lt;BR /&gt;format date yymmdd10.;&lt;BR /&gt;date = input('2016-01-01',yymmdd10.);run;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302722#M64224</guid>
      <dc:creator>nash_sas</dc:creator>
      <dc:date>2016-10-05T17:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302728#M64226</link>
      <description>&lt;P&gt;This does not work because the "dates" in my orginial data are actually character variables. I need to convert the character "dates" to numeric before I can actually make them into SAS dates. I just can't figure out how...everything I try gives me an error or all missing values&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302728#M64226</guid>
      <dc:creator>trt3s</dc:creator>
      <dc:date>2016-10-05T17:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302729#M64227</link>
      <description>&lt;P&gt;The suggested solution does work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to plug in the variable names, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;start_sasdate = input(start_date, yymmdd10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can't re-use the same variable name, since a character variable should not be assigned a numeric value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other possibilities if this is not working for you:&amp;nbsp; Maybe your existing variables are not actually character.&amp;nbsp; Maybe that are already SAS dates, with a format being applied for printing purposes.&amp;nbsp; A PROC CONTENTS will reveal that quickly enough.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302729#M64227</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-05T17:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302730#M64228</link>
      <description>&lt;P&gt;I&amp;nbsp;preformed a Proc Contents and this is&amp;nbsp;the result for those variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;Variable Type Len Informat Label&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;DIV align="center"&gt;&lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Start_Date&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;$CHAR50.&lt;/TD&gt;&lt;TD&gt;Start Date&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;DIV class="branch"&gt;&lt;DIV align="center"&gt;&lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Stop_Date&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;$CHAR50.&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Stop Date&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:36:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302730#M64228</guid>
      <dc:creator>trt3s</dc:creator>
      <dc:date>2016-10-05T17:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302732#M64229</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1093"&gt;@nash_sas﻿&lt;/a&gt;&amp;nbsp;gave you the answer. Here's a somewhat wordier version:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data;
date_str = '2016/10/05';
date_num = input(date_str, yymmdd10.);
put 'Numeric date is ' date_num;
put 'Formatted numeric date is ' date_num mmddyy10.;
run;&lt;/PRE&gt;
&lt;P&gt;date_str is your original date as a character string. date_num is its numeric equivalent. Without a format date_num is 20732. If printed using the mmddyy10. format, date_num is 10/05/2016.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302732#M64229</guid>
      <dc:creator>Tim_SAS</dc:creator>
      <dc:date>2016-10-05T17:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302735#M64231</link>
      <description>&lt;P&gt;The INPUT() function should let you convert strings to dates. &amp;nbsp;But you will need to generate a numeric variable to store them as you cannot store them back into the character variable. &amp;nbsp;So if you have the variable DATEVAR you can make a new variable DATE_NUM that has it as a real date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_num = input(datevar,yymmdd10.);
format date_num yymmdd10. ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want the new variable to have the same name again then you will need to rename the variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rename datevar=date_char date_num=datevar ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302735#M64231</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-10-05T17:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302736#M64232</link>
      <description>&lt;P&gt;Your PROC CONTENTS results show one more possibility to guard against.&amp;nbsp; With a $CHAR informat, it is possible&amp;nbsp; your variable contains leading blanks.&amp;nbsp; So protect against that with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;start_sasdate = input(left(start_date), yymmdd10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:44:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302736#M64232</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-05T17:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302738#M64234</link>
      <description>&lt;P&gt;this is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set orig;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;format start_date2&amp;nbsp;yymmdd10.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;start_date2 = input(start_date,yymmdd10.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am still receiving an enormous&amp;nbsp;amount of errors in my log that basically tells me that I have an invalid argument to function input. I may be interrupting the original data wrong, because this is not working. I am still confused as to how you can go directly from a character variable into a SAS&amp;nbsp;date without converting to numeric first. I am sorry, but I am fairly new to SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302738#M64234</guid>
      <dc:creator>trt3s</dc:creator>
      <dc:date>2016-10-05T17:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302739#M64235</link>
      <description>&lt;P&gt;Post the log with the code and the error messages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By any chance do you have dummy values such as 9999/99/99 for missing dates? 99 are not acceptable months or days and will generate errors.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302739#M64235</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-05T17:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302740#M64236</link>
      <description>&lt;P&gt;That's a separate question that could be addressed in due time ... how does the INPUT function convert from character to numeric.&amp;nbsp; First, though, see if this clears up the problem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set orig;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;format start_date2&amp;nbsp;yymmdd10.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;start_date2 = input( left(start_date),yymmdd10.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302740#M64236</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-05T17:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302741#M64237</link>
      <description>666 data test;&lt;BR /&gt;667 set orig;&lt;BR /&gt;668 start_date2 = input(start_date, yymmdd10.);&lt;BR /&gt;669 format start_date2 yymmdd10.;&lt;BR /&gt;670 run;&lt;BR /&gt;&lt;BR /&gt;NOTE: Invalid argument to function INPUT at line 668 column 15.&lt;BR /&gt;&lt;BR /&gt;***this NOTE: Invalid argument is repeated about 10 more times then it goes on to say***&lt;BR /&gt;&lt;BR /&gt;NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to&lt;BR /&gt;missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;34 at 668:15&lt;BR /&gt;NOTE: There were 14186 observations read from the data set WORK.orig&lt;BR /&gt;NOTE: The data set WORK.TEST has 14186 observations and 36 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.56 seconds&lt;BR /&gt;cpu time 0.10 seconds&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302741#M64237</guid>
      <dc:creator>trt3s</dc:creator>
      <dc:date>2016-10-05T17:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302742#M64238</link>
      <description>&lt;P&gt;This is not necessarily a bad result.&amp;nbsp; This is saying that out of 14,186 observations, 34 had an incoming date value that wasn't valid.&amp;nbsp; The log messages will give you more detail about what is actually in those incoming dates.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302742#M64238</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-05T17:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302743#M64239</link>
      <description>&lt;P&gt;Okay, so when I look into my contents window it is correctly formatted... Why am I still getting this gigantic amount of errors in my log window?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 18:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302743#M64239</guid>
      <dc:creator>trt3s</dc:creator>
      <dc:date>2016-10-05T18:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302744#M64240</link>
      <description>&lt;P&gt;Well, the log is messy but it doesn't represent a lot of observations.&amp;nbsp; let's clean it up and see where the problem comes from:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set orig;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;format start_date2&amp;nbsp;yymmdd10.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;start_date2 = input( start_date, ??yymmdd10.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if start_date2 = . then put start_date=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It doesn't appear to be the left-hand justification.&amp;nbsp; So for now I took out the LEFT function.&amp;nbsp; The ?? will suppress all those messages&amp;nbsp; you were getting.&amp;nbsp; And the PUT statement will give you more succinct messages for the problem cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 18:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302744#M64240</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-05T18:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302751#M64246</link>
      <description>&lt;P&gt;thank you!!! every single one of you have been life savers!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 18:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302751#M64246</guid>
      <dc:creator>trt3s</dc:creator>
      <dc:date>2016-10-05T18:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302762#M64254</link>
      <description>&lt;P&gt;So what was the issue? What was your final solution? I'm just curious because I've been following this topic...&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 19:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-to-SAS-Dates/m-p/302762#M64254</guid>
      <dc:creator>JediApprentice</dc:creator>
      <dc:date>2016-10-05T19:26:06Z</dc:date>
    </item>
  </channel>
</rss>

