<?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 Importing Excel Date as number (YYYYMM) into SAS as Date. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-Excel-Date-as-number-YYYYMM-into-SAS-as-Date/m-p/796521#M255607</link>
    <description>&lt;P&gt;Hi all. I'm looking to move a current Excel process into SAS, for convenience, however, I have an issue stemming from the fact the base data I have to work with is currently only available to me in Excel and will require importing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of my columns in Excel is a "date" column, written as YYYYMM (so, October 2015 would be 201510). This is stored in Excel under General format and not as a date, so when I import the sheet to SAS, it doesn't recognise that 201510 is supposed to be October 2015.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not have access to the base data itself (this is provided by a separate team) and would like to avoid having to manually alter the column every time it's received, if at all possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I can import this, so SAS recognises the column as a list of dates, or so SAS converts the string to a format it can recognise as a date?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 11:53:27 GMT</pubDate>
    <dc:creator>AlexPanebianco</dc:creator>
    <dc:date>2022-02-16T11:53:27Z</dc:date>
    <item>
      <title>Importing Excel Date as number (YYYYMM) into SAS as Date.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Excel-Date-as-number-YYYYMM-into-SAS-as-Date/m-p/796521#M255607</link>
      <description>&lt;P&gt;Hi all. I'm looking to move a current Excel process into SAS, for convenience, however, I have an issue stemming from the fact the base data I have to work with is currently only available to me in Excel and will require importing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of my columns in Excel is a "date" column, written as YYYYMM (so, October 2015 would be 201510). This is stored in Excel under General format and not as a date, so when I import the sheet to SAS, it doesn't recognise that 201510 is supposed to be October 2015.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not have access to the base data itself (this is provided by a separate team) and would like to avoid having to manually alter the column every time it's received, if at all possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I can import this, so SAS recognises the column as a list of dates, or so SAS converts the string to a format it can recognise as a date?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 11:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Excel-Date-as-number-YYYYMM-into-SAS-as-Date/m-p/796521#M255607</guid>
      <dc:creator>AlexPanebianco</dc:creator>
      <dc:date>2022-02-16T11:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Excel Date as number (YYYYMM) into SAS as Date.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Excel-Date-as-number-YYYYMM-into-SAS-as-Date/m-p/796532#M255612</link>
      <description>&lt;P&gt;You only need a simple conversion step after import:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
date = 201510;
run;

data want;
set have;
format date yymmn6.;
date = input(put(date,6.),yymmn6.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you can read the date correctly if you save the spreadsheet to a csv file and read the column from that with the YYMMN6. informat.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 12:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Excel-Date-as-number-YYYYMM-into-SAS-as-Date/m-p/796532#M255612</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-16T12:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Excel Date as number (YYYYMM) into SAS as Date.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Excel-Date-as-number-YYYYMM-into-SAS-as-Date/m-p/796534#M255613</link>
      <description>&lt;P&gt;You could also read this in with a DATA step. If the column is formatted General with only digits in it:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASJedi_0-1645016258215.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68525iE378A25EF25CB7BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASJedi_0-1645016258215.png" alt="SASJedi_0-1645016258215.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;it's probably being read into SAS as a numeric, and something like this would do the trick:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname xl xlsx "c:\temp\have.xlsx";
data want;
   set xl.have;
   date=mdy(mod(DateAsNumber,100),1,int(DateAsNumber/100));
   format date mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure SQL: Query Results" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;DateAsNumber&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;date&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202201&lt;/TD&gt;
&lt;TD class="r data"&gt;01/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202202&lt;/TD&gt;
&lt;TD class="r data"&gt;02/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202203&lt;/TD&gt;
&lt;TD class="r data"&gt;03/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202204&lt;/TD&gt;
&lt;TD class="r data"&gt;04/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202205&lt;/TD&gt;
&lt;TD class="r data"&gt;05/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202206&lt;/TD&gt;
&lt;TD class="r data"&gt;06/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202207&lt;/TD&gt;
&lt;TD class="r data"&gt;07/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202208&lt;/TD&gt;
&lt;TD class="r data"&gt;08/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202209&lt;/TD&gt;
&lt;TD class="r data"&gt;09/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202210&lt;/TD&gt;
&lt;TD class="r data"&gt;10/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202211&lt;/TD&gt;
&lt;TD class="r data"&gt;11/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;202212&lt;/TD&gt;
&lt;TD class="r data"&gt;12/01/2022&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 12:59:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Excel-Date-as-number-YYYYMM-into-SAS-as-Date/m-p/796534#M255613</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2022-02-16T12:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Excel Date as number (YYYYMM) into SAS as Date.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Excel-Date-as-number-YYYYMM-into-SAS-as-Date/m-p/797638#M313594</link>
      <description>Excellent, thanks for this (and apologies for my slow response). I'll give this a try.</description>
      <pubDate>Mon, 21 Feb 2022 18:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Excel-Date-as-number-YYYYMM-into-SAS-as-Date/m-p/797638#M313594</guid>
      <dc:creator>AlexPanebianco</dc:creator>
      <dc:date>2022-02-21T18:55:21Z</dc:date>
    </item>
  </channel>
</rss>

