<?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: Formatting date from Access import in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Formatting-date-from-Access-import/m-p/69054#M19790</link>
    <description>That worked perfectly. Thank you!&lt;BR /&gt;
&lt;BR /&gt;
(Although, upon further inspection, I realized that all my data was from 2007, and I could have just said 'Year = 2007;' but hey, I've learned something new! And I import from Access all the time)</description>
    <pubDate>Fri, 19 Mar 2010 14:01:20 GMT</pubDate>
    <dc:creator>AAdams</dc:creator>
    <dc:date>2010-03-19T14:01:20Z</dc:date>
    <item>
      <title>Formatting date from Access import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formatting-date-from-Access-import/m-p/69052#M19788</link>
      <description>Hello, &lt;BR /&gt;
I am importing a date from Access 2002-2003 into SAS 9. The date gets imported into SAS as: &lt;BR /&gt;
ddmmmyyyy:hh:mm:ss&lt;BR /&gt;
&lt;BR /&gt;
Even though it is in datetime19, SAS won't read it. I looked up in the documentation and found information on sasdatefmt, but I'm clearly not using it right. &lt;BR /&gt;
&lt;BR /&gt;
Here are some of my attempts:&lt;BR /&gt;
&lt;BR /&gt;
data FluShot2007; /*Previously imported from Access &amp;amp; sorted*/&lt;BR /&gt;
	format Date datetime19.;	&lt;BR /&gt;
	set work.dateinfo (sasdatefmt = (Date = 'Datetime19.'));&lt;BR /&gt;
&lt;BR /&gt;
data flu2007;&lt;BR /&gt;
	merge Patients0708 (keep = PatientID Gender) FluShot2007;&lt;BR /&gt;
	by PatientID;&lt;BR /&gt;
&lt;BR /&gt;
	FluShot = 0;&lt;BR /&gt;
	If VaccineType = 'Flu' then FluShot = 1;&lt;BR /&gt;
&lt;BR /&gt;
	Year = year(Date);&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;2nd Attempt:&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
data flu2007;&lt;BR /&gt;
	merge Patients0708 (keep = PatientID Gender) FluShot2007;&lt;BR /&gt;
	by PatientID;&lt;BR /&gt;
	&lt;BR /&gt;
	format Date datetime19.;	&lt;BR /&gt;
	set work.dateinfo (sasdatefmt = (Date = 'Datetime19.'));&lt;BR /&gt;
	FluShot = 0;&lt;BR /&gt;
	If VaccineType = 'Flu' then FluShot = 1;&lt;BR /&gt;
&lt;BR /&gt;
	Year = year(Date);&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;3rd attempt:&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
data flu2007;&lt;BR /&gt;
	merge Patients0708 (keep = PatientID Gender) FluShot2007;&lt;BR /&gt;
	by PatientID;&lt;BR /&gt;
	&lt;BR /&gt;
	format Date datetime19.;	&lt;BR /&gt;
&lt;BR /&gt;
	FluShot = 0;&lt;BR /&gt;
	If VaccineType = 'Flu' then FluShot = 1;&lt;BR /&gt;
&lt;BR /&gt;
	Year = year(Date);&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
Can someone help tell me what I am doing wrong? Thanks!</description>
      <pubDate>Wed, 17 Mar 2010 20:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formatting-date-from-Access-import/m-p/69052#M19788</guid>
      <dc:creator>AAdams</dc:creator>
      <dc:date>2010-03-17T20:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date from Access import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formatting-date-from-Access-import/m-p/69053#M19789</link>
      <description>Hi:&lt;BR /&gt;
  It looks to me like you have read the documentation:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/acpcref/61891/HTML/default/a003079774.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acpcref/61891/HTML/default/a003079774.htm&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/63023/HTML/default/a001371624.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/63023/HTML/default/a001371624.htm&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/6/413.html" target="_blank"&gt;http://support.sas.com/kb/6/413.html&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
However, my interpretation of the notes is that you use the SASDATEFMT option either in your config file or on your LIBNAME or SET statement when you are using SAS/ACCESS or the various engines to initially READ the data from Oracle or DB2 or Microsoft Access into a SAS data set.&lt;BR /&gt;
&lt;BR /&gt;
Once your data are in SAS data format, then I believe that the SASDATEFMT option will no longer impact the data. You would then need to use other SAS formats, functions or conversion methods to impact the date or create a new variable.&lt;BR /&gt;
&lt;BR /&gt;
You might investigate using the DATEPART function or the TIMEPART function to create new variables, as shown in the code below.&lt;BR /&gt;
     &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data testdate;&lt;BR /&gt;
  bday_time = '15Nov1950:07:15:35'dt;&lt;BR /&gt;
  try1 = year(bday_time);&lt;BR /&gt;
  try2 = year(datepart(bday_time));&lt;BR /&gt;
  month = month(datepart(bday_time));&lt;BR /&gt;
  bday = day(datepart(bday_time));&lt;BR /&gt;
  timeval = timepart(bday_time);&lt;BR /&gt;
run;&lt;BR /&gt;
                  &lt;BR /&gt;
proc print data=testdate;&lt;BR /&gt;
  format bday_time datetime18. timeval time8.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
              &lt;BR /&gt;
Output from above program is:&lt;BR /&gt;
[pre]&lt;BR /&gt;
        Obs             bday_time    try1    try2    month    bday     timeval&lt;BR /&gt;
                 &lt;BR /&gt;
         1       15NOV50:07:15:35      .     1950      11      15      7:15:35&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 17 Mar 2010 20:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formatting-date-from-Access-import/m-p/69053#M19789</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-03-17T20:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting date from Access import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formatting-date-from-Access-import/m-p/69054#M19790</link>
      <description>That worked perfectly. Thank you!&lt;BR /&gt;
&lt;BR /&gt;
(Although, upon further inspection, I realized that all my data was from 2007, and I could have just said 'Year = 2007;' but hey, I've learned something new! And I import from Access all the time)</description>
      <pubDate>Fri, 19 Mar 2010 14:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formatting-date-from-Access-import/m-p/69054#M19790</guid>
      <dc:creator>AAdams</dc:creator>
      <dc:date>2010-03-19T14:01:20Z</dc:date>
    </item>
  </channel>
</rss>

