<?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: Convert Char to Date in SAS Viya in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955539#M42944</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How about that, the code marked correct had a typographical error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the correct code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SAS_date = input(Excel_date,32.) + '30DEC1899'd ;
format SAS_date date9.;&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;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;can this be fixed on the old post at&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Conversion-from-Excel-Date-to-SAS-Date/m-p/781804#M205" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Conversion-from-Excel-Date-to-SAS...&lt;/A&gt;&amp;nbsp; ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Fixed.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jan 2025 20:31:52 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-01-08T20:31:52Z</dc:date>
    <item>
      <title>Convert Char to Date in SAS Viya</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955514#M42939</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using SAS Viya and trying to import excel file into it.&lt;/P&gt;
&lt;P&gt;I have a variable date1 as date in my excel file. The data looks like:&lt;/P&gt;
&lt;P&gt;Date1&lt;/P&gt;
&lt;P&gt;9/12/2024&lt;/P&gt;
&lt;P&gt;9/25/2024&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;This is code(I used the drop down import function and the code is autogenerated):&lt;/P&gt;
&lt;DIV&gt;FILENAME REFFILE DISK 'my routeXXX';&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;PROC IMPORT DATAFILE=REFFILE&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; DBMS=XLSX&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; OUT=WORK.IMPORT1;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; GETNAMES=YES;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;RUN;&lt;/DIV&gt;
&lt;DIV&gt;However, once imported&amp;nbsp; date1 shows up like:&lt;/DIV&gt;
&lt;DIV&gt;45537&lt;/DIV&gt;
&lt;DIV&gt;45560&lt;/DIV&gt;
&lt;DIV&gt;...&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;It seems SAS turned it into number of days from day0 in the system.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Can anyone please help me?&lt;/DIV&gt;
&lt;DIV&gt;Thank you.&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 18:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955514#M42939</guid>
      <dc:creator>GingerJJ</dc:creator>
      <dc:date>2025-01-08T18:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Char to Date in SAS Viya</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955516#M42940</link>
      <description>&lt;P&gt;Excel dates are different than SAS dates when PROC IMPORT is used. In fact, they are off by 60 years and 1 day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi29/068-29.pdf" target="_blank" rel="noopener"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/sugi29/068-29.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Conversion-from-Excel-Date-to-SAS-Date/m-p/781804#M205" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Conversion-from-Excel-Date-to-SAS-Date/m-p/781804#M205&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 18:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955516#M42940</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-01-08T18:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Char to Date in SAS Viya</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955532#M42941</link>
      <description>&lt;P&gt;Thank you. I now understand the problem.&lt;/P&gt;
&lt;P&gt;I tried the code in your second link:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;SAS_date = input(Excel_date,32.) + '30DEC1899'x ;
format SAS_date date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It gives me this error:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ERROR: Invalid hexadecimal constant string '30DEC1899'x.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Right now, the value under my imported Date1 variable is in excel unformatted format as character.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any other tips?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 19:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955532#M42941</guid>
      <dc:creator>GingerJJ</dc:creator>
      <dc:date>2025-01-08T19:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Char to Date in SAS Viya</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955533#M42942</link>
      <description>&lt;P&gt;How about that, the code marked correct had a typographical error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the correct code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SAS_date = input(Excel_date,32.) + '30DEC1899'd ;
format SAS_date date9.;&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;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;can this be fixed on the old post at&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Conversion-from-Excel-Date-to-SAS-Date/m-p/781804#M205" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Conversion-from-Excel-Date-to-SAS...&lt;/A&gt;&amp;nbsp; ?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 19:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955533#M42942</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-01-08T19:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Char to Date in SAS Viya</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955538#M42943</link>
      <description>&lt;P&gt;You have at least one cell in that column of the spreadsheet that has a CHARACTER value instead of a DATE value.&amp;nbsp; That is why PROC IMPORT had to make the variable character instead of numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can eliminate those character cells then PROC IMPORT should be able to make a numeric variable with appropriate DATE values and attach a date type format for displaying them in a human readable style.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 20:29:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955538#M42943</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-08T20:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Char to Date in SAS Viya</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955539#M42944</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How about that, the code marked correct had a typographical error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the correct code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SAS_date = input(Excel_date,32.) + '30DEC1899'd ;
format SAS_date date9.;&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;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;can this be fixed on the old post at&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Conversion-from-Excel-Date-to-SAS-Date/m-p/781804#M205" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Conversion-from-Excel-Date-to-SAS...&lt;/A&gt;&amp;nbsp; ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Fixed.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 20:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955539#M42944</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-08T20:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Char to Date in SAS Viya</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955541#M42945</link>
      <description>&lt;P&gt;Applying an Excel Date format to the column in the spreadsheet prior to importing should avoid having to do any extra conversion in SAS.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 20:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955541#M42945</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2025-01-08T20:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Char to Date in SAS Viya</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955542#M42946</link>
      <description>&lt;P&gt;I did make sure to change it to Date in excel but it didn't help...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 20:54:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955542#M42946</guid>
      <dc:creator>GingerJJ</dc:creator>
      <dc:date>2025-01-08T20:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Char to Date in SAS Viya</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955543#M42947</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393829"&gt;@GingerJJ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I did make sure to change it to Date in excel but it didn't help...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Changing the display style used for the cells will not change the values in the cells.&amp;nbsp; You have to actually remove the character strings.&amp;nbsp; Normally I see that when there is an invalid date, like the 31NOV2024 or 29FEB2023.&amp;nbsp; But also when reading in CSV files generated by programs like R or Python that insert strings like NA for missing values.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 20:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955543#M42947</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-08T20:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Char to Date in SAS Viya</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955573#M42948</link>
      <description>&lt;P&gt;Another option is to save the XLSX as a CSV file and read that with a data step, best, or import the CSV.&lt;/P&gt;
&lt;P&gt;Generally the Excel format applied to the date field will be the result in the CSV and SAS will recognize most of those. And in the case of the mixed numeric/character values the character date that would export from Excel as "9/25/2024" will also generally be read by SAS correctly. A corresponding date format is then typically applied by Proc Import.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 00:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Char-to-Date-in-SAS-Viya/m-p/955573#M42948</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-01-09T00:46:58Z</dc:date>
    </item>
  </channel>
</rss>

