<?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: datetime() syntax with PUT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/datetime-syntax-with-PUT/m-p/380807#M91414</link>
    <description>&lt;P&gt;Note there is a "feature" of the DATATIME &amp;nbsp;format that makes using DATETIME18. useless. Even though 9 character date plus 8 character time plus 1 character separator will fit in 18 characters, the format will NOT&amp;nbsp;use&amp;nbsp;4 digit years if you set the width to 18. You need to use width of at least 19.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 dt=datetime();
 put dt= datetime18.;
 put dt= datetime19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dt=27JUL17:10:40:17
dt=27JUL2017:10:40:17&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Jul 2017 14:43:27 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-07-27T14:43:27Z</dc:date>
    <item>
      <title>datetime() syntax with PUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-syntax-with-PUT/m-p/380458#M91410</link>
      <description>&lt;P&gt;I'm runnint the following code to generate an email from sas. I'd like to put a date stamp with it. While running it I get the error 22-322 from PUT datetime(). What is the proper syntax? Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME outbox EMAIL ("xxx.xxx@xxx.com");

DATA _NULL_;
	FILE outbox
		TO="steve.rogers@ge.com"
		/*TO=("My.Boss@Delta.com" "My.Other.Boss@Delta.com")
		FROM=("Andrew.Hummel@Delta.com")*/
		SUBJECT=("Example of a SAS E-mail with Attachments" )
		/*ATTACH=("/sas_server/reports/Daily_Cancelled_Flight_Report.pdf"
		"/sas_server/reports/Daily_Delayed_Flight_Report.pdf");*/
		;
	PUT " ";
	PUT "Hello,";
	PUT " ";
	PUT datetime();
	/*PUT ("This is an update for ",datetime());*/
	PUT " ";
	PUT "Steve";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jul 2017 14:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-syntax-with-PUT/m-p/380458#M91410</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-07-27T14:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: datetime() syntax with PUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-syntax-with-PUT/m-p/380684#M91412</link>
      <description>&lt;P&gt;Datetime is a function to achieve the stamptime and assign it into a variable.&lt;/P&gt;
&lt;P&gt;Having the variable assigned you need to define a format how to display it in your email.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME outbox EMAIL ("xxx.xxx@xxx.com");

DATA _NULL_;
  dtime = datetime();      /* &amp;lt;&amp;lt;&amp;lt; line added */
	FILE outbox
		TO="steve.rogers@ge.com"
		/*TO=("My.Boss@Delta.com" "My.Other.Boss@Delta.com")
		FROM=("Andrew.Hummel@Delta.com")*/
		SUBJECT=("Example of a SAS E-mail with Attachments" )
		/*ATTACH=("/sas_server/reports/Daily_Cancelled_Flight_Report.pdf"
		"/sas_server/reports/Daily_Delayed_Flight_Report.pdf");*/
		;
	PUT " ";
	PUT "Hello,";
	PUT " ";
/*	PUT datetime(); */
	PUT  dtime datetime19.;   /* line was edited according to Tom's note */
	PUT " ";
	PUT "Steve";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 15:13:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-syntax-with-PUT/m-p/380684#M91412</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-27T15:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: datetime() syntax with PUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-syntax-with-PUT/m-p/380807#M91414</link>
      <description>&lt;P&gt;Note there is a "feature" of the DATATIME &amp;nbsp;format that makes using DATETIME18. useless. Even though 9 character date plus 8 character time plus 1 character separator will fit in 18 characters, the format will NOT&amp;nbsp;use&amp;nbsp;4 digit years if you set the width to 18. You need to use width of at least 19.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 dt=datetime();
 put dt= datetime18.;
 put dt= datetime19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dt=27JUL17:10:40:17
dt=27JUL2017:10:40:17&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jul 2017 14:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-syntax-with-PUT/m-p/380807#M91414</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-27T14:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: datetime() syntax with PUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-syntax-with-PUT/m-p/381006#M91416</link>
      <description>Thanks for the simple solution.</description>
      <pubDate>Thu, 27 Jul 2017 15:00:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-syntax-with-PUT/m-p/381006#M91416</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-07-27T15:00:03Z</dc:date>
    </item>
  </channel>
</rss>

