<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/875568#M345958</link>
    <description>&lt;P&gt;Are you sure you want dots to separate the time elements, and not colons?&lt;/P&gt;
&lt;P&gt;Either roll your own format with PROC FORMAT, or create a temporary string:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;temp_dt = catx(
  ".",
  put(datepart(dt),yymmdd10..),
  put(hour(timepart(dt)),z2.),
  put(minute(timepart(dt)),z2.),
  put(second(timepart(dt)),z2.)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 13 May 2023 05:37:26 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-05-13T05:37:26Z</dc:date>
    <item>
      <title>Dataset with datetime - On Demand for Academics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/875556#M345946</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;do we have any dataset in sas on demand for academics with columns&lt;/P&gt;
&lt;P&gt;1. date e.g. 30NOV2022&lt;/P&gt;
&lt;P&gt;2. datetime e.g. 30NOV2022:21:07:04&lt;/P&gt;
&lt;P&gt;that I can use for testing??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is common practice for converting datetime such that it can enter DB2?&lt;/P&gt;
&lt;P&gt;I mean how to do it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 10:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/875556#M345946</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2023-06-15T10:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/875561#M345951</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416388"&gt;@HeatherNewton&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;do we have any dataset in sas on demand for academics with columns&lt;/P&gt;
&lt;P&gt;1. date e.g. 30NOV2022&lt;/P&gt;
&lt;P&gt;2. datetime e.g. 30NOV2022:21:07:04&lt;/P&gt;
&lt;P&gt;that I can use for testing??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is common practice for converting datetime such that it can enter DB2?&lt;/P&gt;
&lt;P&gt;I mean how to do it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As in your other thread, this depends on the tools available. Do you have SAS/ACCESS for DB/2 installed and licensed, or ACCESS to ODBC? Or do you need to create text files for later import into the DB?&lt;/P&gt;
&lt;P&gt;SAS on Demand does not have any ACCESS modules for relational databases, so you can't test them there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding datasets for testing, such can easioy be created with a DATA step with DATALINES.&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2023 04:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/875561#M345951</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-13T04:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/875563#M345953</link>
      <description>&lt;P&gt;I need to convert sas dataset to csv and load csv into DB2&lt;/P&gt;
&lt;P&gt;I want datetime looking like 30NOV2022:21:07:04 (datetime20.) in sas data set to look like 2022-11-30.21.12.57 in db2&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2023 05:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/875563#M345953</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2023-05-13T05:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/875568#M345958</link>
      <description>&lt;P&gt;Are you sure you want dots to separate the time elements, and not colons?&lt;/P&gt;
&lt;P&gt;Either roll your own format with PROC FORMAT, or create a temporary string:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;temp_dt = catx(
  ".",
  put(datepart(dt),yymmdd10..),
  put(hour(timepart(dt)),z2.),
  put(minute(timepart(dt)),z2.),
  put(second(timepart(dt)),z2.)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 May 2023 05:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/875568#M345958</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-13T05:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/880886#M348062</link>
      <description>&lt;P&gt;how can I amend it such that I get output format like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2009-01-07-15.33.31&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;instead of&amp;nbsp;&amp;nbsp;2009-01-07.15.33.31 from your code?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 10:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/880886#M348062</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2023-06-15T10:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/880889#M348065</link>
      <description>&lt;P&gt;Roll your own format with &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1xidhqypi0fnwn1if8opjpqpbmn.htm" target="_blank" rel="noopener"&gt;PROC FORMAT&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;picture mydt
  low - high='%Y-%0m-%0d-%0H.%0M.%0S' (datatype=datetime)
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jun 2023 10:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/880889#M348065</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-15T10:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/880960#M348107</link>
      <description>&lt;P&gt;You could use the E8601DT format and then convert the T and : into the separators you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  sas_datetime=datetime();
  db2_dtstring=translate(put(sas_datetime,e8601dt.),'-.','T:');
  format sas_datetime e8601dt.;
  put (_all_) (=/);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;sas_datetime=2023-06-15T11:27:39
db2_dtstring=2023-06-15-11.27.39&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jun 2023 15:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/880960#M348107</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-15T15:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset with datetime - On Demand for Academics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/880962#M348109</link>
      <description>&lt;P&gt;IME having it stored as a datetime in SAS will allow it to upload properly to db2.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dates will not be uploaded correctly, they need to be converted to datetimes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Formats didn't matter, but as always, test it out on your system.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 15:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/880962#M348109</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-15T15:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/882389#M348619</link>
      <description>&lt;P&gt;I tried this and got following error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LINE and COLUMN cannot be determined.&lt;/P&gt;
&lt;P&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred&lt;/P&gt;
&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 08:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/882389#M348619</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2023-06-26T08:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/882392#M348621</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro conversion(filename);
options obs=10;
data test.&amp;amp;filename.;
set test.&amp;amp;filename.;
last_update_datetime_1=translate(put(last_update_datetime, e8601dt.),'-.','T:');
format last_update_datetime e8601dt.;run;
put(_all) (=/);
drop last_update_datetime;
rename last_update_datetime_1=last_update_datetime;
run;

filename exprt "/mpoint/test/&amp;amp;filename..csv" encoding="utf-8";
proc export data=test.&amp;amp;filename. outfile=exprt dbms=csv replace; run;
%mend;
&lt;/PRE&gt;
&lt;P&gt;I tried the above and got the following error,&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;180:LINE and COLUMN cannot be determind.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;and the above repeat three times&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what has gone wrong??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 08:25:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/882392#M348621</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2023-06-26T08:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/882394#M348622</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416388"&gt;@HeatherNewton&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You appear to have an extra &lt;FONT face="courier new,courier"&gt;run&lt;/FONT&gt; statement that should be removed. Try changing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format last_update_datetime e8601dt.;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format last_update_datetime e8601dt.;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 08:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/882394#M348622</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2023-06-26T08:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/882414#M348625</link>
      <description>&lt;P&gt;You have a RUN statement in the middle of the data step.&amp;nbsp; If you get in the habit of no more than one statement per line those types of mistakes will be easier to spot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you really have a variable named _ALL ?&lt;/P&gt;
&lt;P&gt;Or did you want to print ALL of the variables?&amp;nbsp; If the latter then you need to use _ALL_ variable list.&lt;/P&gt;
&lt;P&gt;Or better still once you get it to work you can remove the PUT statement completely as it is not really doing anything other than providing evidence that the conversion worked.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 11:58:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/882414#M348625</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-26T11:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset with datetime - On Demand for Academics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/882426#M348627</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;do we have any dataset in sas on demand for academics with columns&lt;/P&gt;
&lt;P&gt;1. date e.g. 30NOV2022&lt;/P&gt;
&lt;P&gt;2. datetime e.g. 30NOV2022:21:07:04&lt;/P&gt;
&lt;P&gt;that I can use for testing??&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try checking the information about the variables and seeing if any of the datasets have both DATE and DATETIME variables.&amp;nbsp; You can use the FMTINFO() function to find out what type of format is attached to a variable.&amp;nbsp; It wants just the NAME of the format so use the output of PROC CONTENTS instead of the DICTIONARY.COLUMNS view.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=sashelp._all_ noprint out=contents; run;
data want ;
do until (last.memname);
  set contents;
  by memname;
  if fmtinfo(format,'cat')='date' then datevar=name;
  if fmtinfo(format,'cat')='datetime' then dtvar=name;
end;
if not missing(datevar) and not missing(dtvar);
keep memname datevar dtvar ;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1687782951091.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85393i4855793FAFEB69EA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1687782951091.png" alt="Tom_0-1687782951091.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;So let's look at what it contains&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_1-1687783035866.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85394i1E9B4771C62CE934/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_1-1687783035866.png" alt="Tom_1-1687783035866.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 12:38:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dataset-with-datetime-On-Demand-for-Academics/m-p/882426#M348627</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-26T12:38:55Z</dc:date>
    </item>
  </channel>
</rss>

