<?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: How to extract a date stamp from excel file inside in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375263#M89933</link>
    <description>&lt;P&gt;Thank you Kurt. You might be correct to export data from EXCEL to CSV and then extract date. But my assignment is to get from EXCEL. Thank you so much for replying.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jul 2017 11:03:50 GMT</pubDate>
    <dc:creator>buddha_d</dc:creator>
    <dc:date>2017-07-12T11:03:50Z</dc:date>
    <item>
      <title>How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375169#M89915</link>
      <description>&lt;P&gt;How can I extract date (07-11-2016) from this excel file from this data and make a sas data with different format and lengths?&lt;/P&gt;&lt;P&gt;If you can send the SAS code that would be great and I am sending dummy data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 00:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375169#M89915</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-07-12T00:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375177#M89917</link>
      <description>&lt;P&gt;DATEPART() will extract the date from a datetime field.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 02:02:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375177#M89917</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-12T02:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375185#M89919</link>
      <description>&lt;P&gt;Date is in the header row as well as in the 4 or 5 th row. Datepart don't work there&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 03:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375185#M89919</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-07-12T03:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375186#M89920</link>
      <description>&lt;P&gt;I can't guess what you want.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 03:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375186#M89920</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-12T03:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375187#M89921</link>
      <description>&lt;P&gt;/orry Reeza, I want to extract date 07-11-2016 date stamp extracted from this excel sheet (it is there in firstrow , title column, datetime and second column (where you see date: 07-11-2016). I need to see this date stamp along with other variables. I was able to import data , but time stamp is the one giving me challenges.&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 03:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375187#M89921</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-07-12T03:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375188#M89922</link>
      <description>&lt;P&gt;Please let me know if you need any more clarification.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 03:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375188#M89922</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-07-12T03:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375214#M89928</link>
      <description>&lt;P&gt;Export from Excel to a text file (csv), and read that with a custom data step.&lt;/P&gt;
&lt;P&gt;- the exported file can be viewed with any text editor&lt;/P&gt;
&lt;P&gt;- the file format of csv does not change at the whim of Microsoft&lt;/P&gt;
&lt;P&gt;- consistent data structure is guaranteed, changes in the Excel file will result in SAS messages&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doing the transfer from Excel to SAS in this way has been proven to be the best option for &amp;gt; 2 decades here.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 06:05:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375214#M89928</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-12T06:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375263#M89933</link>
      <description>&lt;P&gt;Thank you Kurt. You might be correct to export data from EXCEL to CSV and then extract date. But my assignment is to get from EXCEL. Thank you so much for replying.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 11:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375263#M89933</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-07-12T11:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375276#M89943</link>
      <description>&lt;PRE&gt;options obs=1;
PROC IMPORT OUT= WORK.tmp 
            DATAFILE= "C:\Temp\DUMMY DATA.xlsx" 
            DBMS=EXCEL REPLACE;
     RANGE="Sheet1$"; 
     GETNAMES=NO;
     MIXED=NO;
     SCANTEXT=NO;
     USEDATE=NO;
     SCANTIME=NO;
RUN;
options obs=max;

data tmp;
   set tmp;
   length date $32;
   array all _character_;
   call missing(date);
   do over all;
      if prxmatch('/.*(\d\d-\d\d-\d\d\d\d).*/',all) then date=prxchange('s/.*(\d\d-\d\d-\d\d\d\d).*/$1/',-1,all);
   end;
   keep date;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jul 2017 11:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375276#M89943</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-07-12T11:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375286#M89948</link>
      <description>&lt;P&gt;Oligolas, Thanks for responding with code. I can extract the date Yah !!!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much. Can you share your logic in the second tmp dataset. I am bit baffled by it. thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;array all _character_;
   call missing(date);
   do over all;
      if prxmatch('/.*(\d\d-\d\d-\d\d\d\d).*/',all) then date=prxchange('s/.*(\d\d-\d\d-\d\d\d\d).*/$1/',-1,all);
   end;
   keep date;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 12:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375286#M89948</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-07-12T12:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375288#M89950</link>
      <description>&lt;P&gt;Oligolas, Thanks for responding with code. I can extract the date Yah !!!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much. Can you share your logic in the second tmp dataset. I am bit baffled by it. thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array all _character_;&lt;BR /&gt;call missing(date);&lt;BR /&gt;do over all;&lt;BR /&gt;if prxmatch('/.*(\d\d-\d\d-\d\d\d\d).*/',all) then date=prxchange('s/.*(\d\d-\d\d-\d\d\d\d).*/$1/',-1,all);&lt;BR /&gt;end;&lt;BR /&gt;keep date;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 12:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375288#M89950</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-07-12T12:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375294#M89951</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm glad it helps.&lt;/P&gt;&lt;P&gt;Logic:&lt;/P&gt;&lt;P&gt;Define an array containing the&amp;nbsp;character variables of the dataset&lt;/P&gt;&lt;P&gt;Loop over all these variables&lt;/P&gt;&lt;P&gt;For each of them, look with a regular expression if they contain something that looks like a date&lt;/P&gt;&lt;P&gt;If yes (I expect only one of these variables to contain a date), extract the date.&lt;/P&gt;&lt;P&gt;'s/.*(\d\d-\d\d-\d\d\d\d).*/$1/' means:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;s/&lt;/STRONG&gt; start of the string&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;.*&lt;/STRONG&gt; any character&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(\d\d-\d\d-\d\d\d\d)&lt;/STRONG&gt; if anything is found that looks like a date, capture it, in the first group. Brackets determine a group.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;.*&lt;/STRONG&gt; any character&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/&lt;/STRONG&gt; end of the string&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;$1&lt;/STRONG&gt; the replacement string (my first capturing group)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/&lt;/STRONG&gt; end of the regex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That all means:&lt;/P&gt;&lt;P&gt;Look for something that starts with anything, I don't mind what,&lt;/P&gt;&lt;P&gt;followed by something that looks like a date,&lt;/P&gt;&lt;P&gt;followed by anything, I don't mind what&lt;/P&gt;&lt;P&gt;If you have it, replace this stuff by the thing that looks like a date (= extract the date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and write it out to the 'date' variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe take a look at this tutorial if you're not familiar with regular expressions:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=WtQLRGW_W2A" target="_blank"&gt;https://www.youtube.com/watch?v=WtQLRGW_W2A&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/14071iA1F7D0F21679E13E/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="screenshot_18.png" title="screenshot_18.png" /&gt;</description>
      <pubDate>Wed, 12 Jul 2017 13:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375294#M89951</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-07-12T13:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375332#M89965</link>
      <description>&lt;P&gt;Specify the RANGE option on PROC IMPORT. You can use the RANGE to specify a single cell to import each of the dates individually from the Excel file. Tedious but no real way around something like that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 14:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375332#M89965</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-12T14:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375540#M90042</link>
      <description>&lt;P&gt;Thank you All for your help&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 23:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/375540#M90042</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-07-12T23:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/383213#M91449</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/77163"&gt;@Oligolas&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Hi Oligolas,&lt;/P&gt;&lt;P&gt;Excellent solution. I have almost the same problem except only difference is my excel date is in d/mm/yyyy format. The same code you provided resulted in sas data with date variable blank. Could you please help modify your prxmatch code in the context of my data attached here?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desirable output would be a sas data that contains all variables from the excel file with "date of birth" variable converted to any sas date format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 18:21:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/383213#M91449</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-07-27T18:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/383436#M91455</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;Your problem doesn't appear to the be the same. He had some unformatted excel files with dates in mulitple columns. You appear to have a well structured file and can use much simpler approaches.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;For starters, what type/format are your dates imported in? You should start your own question or try and find an example that better aligns with your question. This is like using a hammer with a thumbtack approach.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 19:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/383436#M91455</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-27T19:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/383455#M91458</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;Thanks for your comment. I will create a new post if i can't figure it out myself in the next hour or so.&lt;/P&gt;&lt;P&gt;As per your inquiries,&lt;BR /&gt;"Date of birth" variable in excel was imported to "15MAR2014:00:00:00" DATETIME19.&amp;nbsp;format in SAS. I tried below approaches so far:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Approach1:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=datepart(date_of_birth);
date1=input(put(date,8.),yymmdd8.);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Result: date1 variable with lots of sporadic missing with 5 digit numbers such as:&amp;nbsp;15367.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Approach2:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Shifting starting point in original excel file then import.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SAS_birthdate = excel_birthdate - 21916;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Result2: The same. Bunch of numbers in the close range of 15540 here and there with huge missing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="date_support.png" style="width: 293px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14148i62D0D6F40100D90B/image-size/large?v=v2&amp;amp;px=999" role="button" title="date_support.png" alt="date_support.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 19:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/383455#M91458</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-07-27T19:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/383463#M91460</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=datepart(date_of_birth);
format date date9.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jul 2017 19:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/383463#M91460</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-27T19:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date stamp from excel file inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/383491#M91467</link>
      <description>Thank you very much. It solved the problem.</description>
      <pubDate>Thu, 27 Jul 2017 20:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-date-stamp-from-excel-file-inside/m-p/383491#M91467</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-07-27T20:33:57Z</dc:date>
    </item>
  </channel>
</rss>

