<?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 type date to SAS date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250283#M47182</link>
    <description>&lt;P&gt;Please supply some example values. You may have used the wrong format. Also state which ERROR message you got.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Feb 2016 11:48:18 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-02-16T11:48:18Z</dc:date>
    <item>
      <title>Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250281#M47181</link>
      <description>&lt;P&gt;In my table grocery i'm having a variable named "couponexpiry" which has been imported into sas as a character, I am trying below code for converting it into date but in output only missing values I can see. Please help. &amp;nbsp;What is wrong in code ??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1; 
set class5.grocery_coupons; 
date_exp=input(couponexpiry,date9.); 
format date_exp date9.; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Feb 2016 11:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250281#M47181</guid>
      <dc:creator>BhavukZutshi</dc:creator>
      <dc:date>2016-02-16T11:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250283#M47182</link>
      <description>&lt;P&gt;Please supply some example values. You may have used the wrong format. Also state which ERROR message you got.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 11:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250283#M47182</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-02-16T11:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250286#M47183</link>
      <description>I have not got any error message. Only in output I am getting missing values. couponexpiry variable has dates in char format which i wanted in date format.</description>
      <pubDate>Tue, 16 Feb 2016 11:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250286#M47183</guid>
      <dc:creator>BhavukZutshi</dc:creator>
      <dc:date>2016-02-16T11:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250287#M47184</link>
      <description>&lt;P&gt;Please provide sample values. What does your data look like? There's nothing 'wrong' about your code that we can see, but we can't see your data....&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 11:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250287#M47184</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-16T11:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250291#M47187</link>
      <description>&lt;P&gt;My original data looked like below : couponexpiry 20-02-2014 21-02-2014 22-02-2014 23-02-2014 via using import command&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile ='/folders/myfolders/grocery_coupons.xls' out=class5.grocery_coupons dbms=xls replace; 
sheet= "Data" ;
getnames=Yes; 
datarow=2;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I got the table in SAS but my couponexpiry column came as below couponexpiry 41690 41691 41692 41693 as char format so i used the aforementioned code in earlier post to convert this into date type format. I could not understand what error or mistake I'm making which is giving me missing values, may be a silly mistake. Help required.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 12:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250291#M47187</guid>
      <dc:creator>BhavukZutshi</dc:creator>
      <dc:date>2016-02-16T12:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250293#M47188</link>
      <description>&lt;P&gt;Your format isn't date9, its yymmdd10.&lt;/P&gt;
&lt;P&gt;Change your input statement to reflect this and your code should work - barring any other errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please use the Insert Code icon above to include code in your posts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT:&lt;/P&gt;
&lt;P&gt;If your values look like numbers, are they numeric or character? It doesn't make sense that they've converted to numeric but are stored as chars. &amp;nbsp;You can try applying a format and see if it works, without an input statement.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 12:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250293#M47188</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-16T12:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250302#M47190</link>
      <description>&lt;P&gt;You DO have messages in the log. Everytime data does not correspond to the format in an INPUT statement, you get NOTE: in your log&lt;/P&gt;
&lt;P&gt;READ.THE.LOG.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the looks, you need to use ddmmyy10. as the input format.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 12:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250302#M47190</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-02-16T12:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250303#M47191</link>
      <description>&lt;P&gt;Save data as .CSV from Excel, inspect it with a text editor, and then write a correct data step to read from the .CSV. .XLS is NOT suited for data transfer.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 12:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250303#M47191</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-02-16T12:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250318#M47193</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/70584"&gt;@BhavukZutshi﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Those "date values" 41690, 41691 etc. are Excel date values (with 1st Jan 1900 being day 1 and including the non-existent date 29 Feb 1900). You can simply subtract 21916 to obtain SAS date values, provided that you are not dealing with dates before 1st March 1900 (cf. &lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-convert-an-alpha-data-20081223-that-represents-a-date/td-p/122023" target="_blank"&gt;this older thread&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1; 
couponexpiry='41690'; 
date_exp=input(couponexpiry, 8.)-21916; 
format date_exp date9.; 
run; /* formatted result: 20FEB2014 */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Feb 2016 13:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250318#M47193</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-16T13:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250321#M47194</link>
      <description>&lt;P&gt;Although LibreOffice and OpenOffice work with data from Excel, the pure geniuses there managed to get rid of the 29feb1900 error by Applied Advanced Mathematics. They just moved day 1 to 31dec1899. And their software can therefore deal with dates before that, what a miracle!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 13:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250321#M47194</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-02-16T13:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250516#M47236</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure whether your query is solved or not....but I guess...following code will help.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
coupunexpiry='20-02-2014';
output;
coupunexpiry='21-02-2014';
output;
coupunexpiry='22-02-2014';
output;
coupunexpiry='23-02-2014';
output;
run;

data want;
set have;
coupunexpiry=compress(coupunexpiry,'-');
num_dt=input(coupunexpiry,ddmmyy10.);
format num_dt date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Abd.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 06:46:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250516#M47236</guid>
      <dc:creator>ad123123</dc:creator>
      <dc:date>2016-02-17T06:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character type date to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250562#M47248</link>
      <description>Thanks my problem got solved. Mainly by first using file import as .csv and then putting in the right format which was ddmmyy10. Thanks to all the people for giving valuable suggestions and feedback.</description>
      <pubDate>Wed, 17 Feb 2016 10:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-type-date-to-SAS-date/m-p/250562#M47248</guid>
      <dc:creator>BhavukZutshi</dc:creator>
      <dc:date>2016-02-17T10:57:31Z</dc:date>
    </item>
  </channel>
</rss>

