<?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: Create timestamp variable in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239389#M44026</link>
    <description>&lt;P&gt;The DATETIME() function will return the current datetime (aka timestamp) value.&lt;/P&gt;
&lt;P&gt;Not sure how you want to use that but you could store it in macro variable using&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let currdt=%sysfunc(datetime());&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Dec 2015 18:50:46 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2015-12-15T18:50:46Z</dc:date>
    <item>
      <title>Create timestamp variable in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239386#M44025</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know, how do i create timestamp variable capturing execution start date and time and execution end date and time in sas dataset.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2015 18:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239386#M44025</guid>
      <dc:creator>dkanand86</dc:creator>
      <dc:date>2015-12-15T18:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create timestamp variable in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239389#M44026</link>
      <description>&lt;P&gt;The DATETIME() function will return the current datetime (aka timestamp) value.&lt;/P&gt;
&lt;P&gt;Not sure how you want to use that but you could store it in macro variable using&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let currdt=%sysfunc(datetime());&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2015 18:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239389#M44026</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-12-15T18:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create timestamp variable in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239396#M44031</link>
      <description>&lt;P&gt;Are you wanting to put the date and time the program executes and finishes into a data set, or are you wanting to just put the date and time to the log at the beginning of the run and again at the end?&amp;nbsp; You can do either, although if you put it into the data set it will be there for every observation.&amp;nbsp; You could do somehting like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data final;
set have;
format StartDate mmddyy10. StartTime time10.;
StartDate=date();
StartTime=time();
run;

/*** Other program code ***/

data final;
set final;
format EndDate mmddyy10. EndTime time10.;
EndDate=date();
EndTime=time();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise, you could always print the date and time to the log once the program begins execution and again when it completes.&amp;nbsp; That would be like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
put "====================================";
put "Start Date: %sysfunc(date(),worddate.)";
put "Start Time: %sysfunc(time(),time.)";
put "====================================";
run;

/*** Other program code ***/

data _NULL_;
put "====================================";
put "End Date: %sysfunc(date(),worddate.)";
put "End Time: %sysfunc(time(),time.)";
put "====================================";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Dec 2015 19:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239396#M44031</guid>
      <dc:creator>dcruik</dc:creator>
      <dc:date>2015-12-15T19:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create timestamp variable in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239439#M44047</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code solution will help in:&lt;/P&gt;
&lt;P&gt;1. creating timestamp in dataset&lt;/P&gt;
&lt;P&gt;2. creating timestamp in log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2015 21:31:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239439#M44047</guid>
      <dc:creator>dkanand86</dc:creator>
      <dc:date>2015-12-15T21:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create timestamp variable in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239443#M44048</link>
      <description>&lt;P&gt;One more thing, please can you provide solution for date time together instead of date and time seperately.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2015 21:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239443#M44048</guid>
      <dc:creator>dkanand86</dc:creator>
      <dc:date>2015-12-15T21:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create timestamp variable in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239445#M44050</link>
      <description>&lt;P&gt;Just use the datetime() instead of date() and time().&amp;nbsp; Like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data final;
set have;
format StartDateTime datetime20.;
StartDateTime=datetime();
run;

/*** Other program code ***/

data final;
set final;
format EndDateTime datetime20.;
EndDateTime=datetime();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if you're printing to the log, like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
put "=============================================";
put "Start Date &amp;amp; Time: %sysfunc(datetime(),datetime.)";
put "=============================================";
run;

/*** Other program code ***/

data _NULL_;
put "=============================================";
put "End Date &amp;amp; Time: %sysfunc(datetime(),datetime.)";
put "=============================================";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Dec 2015 21:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-timestamp-variable-in-sas/m-p/239445#M44050</guid>
      <dc:creator>dcruik</dc:creator>
      <dc:date>2015-12-15T21:53:38Z</dc:date>
    </item>
  </channel>
</rss>

