<?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: format date and time in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910136#M40735</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jan 2024 19:19:52 GMT</pubDate>
    <dc:creator>knighsson</dc:creator>
    <dc:date>2024-01-02T19:19:52Z</dc:date>
    <item>
      <title>format date and time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910120#M40729</link>
      <description>&lt;DIV&gt;My code is below.&lt;/DIV&gt;
&lt;DIV&gt;The variable "Occ_Time" is in the format of "DATETIME." in the original dataset, but when I print out the new dataset, it becomes numbers such as "1961799000". Can you please teach me how to format the "Occ_Time" as DATETIME. in the new dataset ? Thank you!&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;proc transpose data=el.OCC&amp;nbsp; out=el.wide prefix=Occ_Name_;&lt;/DIV&gt;
&lt;DIV&gt;by UserName_numbers RecallNo;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; var Occ_Name Occ_Time ;&lt;/DIV&gt;
&lt;DIV&gt;format Occ_Time DATETIME.;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Jan 2024 18:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910120#M40729</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2024-01-02T18:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: format date and time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910124#M40730</link>
      <description>&lt;P&gt;I'm not sure what the problem is, as you didn't share a portion of your real data with us. Please do that, following these &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;examples and instructions&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As things stand now, I cannot reproduce this problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fake;
    occ_time='01JAN2024:00:00:00'dt; output;
    occ_time='01JAN2024:01:15:00'dt; output;
    format occ_time datetime.;
run;

proc transpose data=fake out=transp prefix=occ_name_;
    var occ_time;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Produces this output&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="PaigeMiller_0-1704220815340.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92178i9D9B7A374CE698B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_0-1704220815340.png" alt="PaigeMiller_0-1704220815340.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 18:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910124#M40730</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-02T18:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: format date and time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910130#M40731</link>
      <description>&lt;P&gt;Thank you for your response.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original dataset looks like this:&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 828px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92179i153EFEC21357CC60/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The wanted/new dataset looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 716px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92180iE9E4CF4C79E9DA5B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But I want the "Occ-Time" is still as "DATETIME." format rather than numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 18:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910130#M40731</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2024-01-02T18:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: format date and time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910133#M40733</link>
      <description>&lt;P&gt;Your code looks correct.&amp;nbsp; Here is an example you can run for yourself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  do now=datetime(),datetime()+'24:00:00't ;
    output;
  end;
run;
proc print;
run;

proc transpose data=have out=want1 ;
 var now;
run;
proc print;
run;

proc transpose data=have out=want2 ;
 var now;
 format now datetime19.;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But perhaps the variable names are not what you think they are?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your picture seems to have two columns with a header of OCC_TIME.&lt;/P&gt;
&lt;P&gt;Which one did you use when you created the variable named OCC_TIME you used in your SAS code?&amp;nbsp; What format did it have attached to it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 19:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910133#M40733</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-02T19:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: format date and time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910134#M40734</link>
      <description>&lt;P&gt;What happens if in PROC TRANSPOSE you use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=el.OCC  out=el.wide prefix=Occ_Name_;
    by UserName_numbers RecallNo;
    var Occ_Time ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jan 2024 19:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910134#M40734</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-02T19:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: format date and time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910136#M40735</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 19:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910136#M40735</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2024-01-02T19:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: format date and time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910137#M40736</link>
      <description>&lt;P&gt;Ok, this will work. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 19:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910137#M40736</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2024-01-02T19:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: format date and time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910169#M40737</link>
      <description>&lt;P&gt;Actually in SAS your starting data cannot appear as shown as you show two variables named OCC_time and SAS will not allow that in a single data set. One of those is apparently a TIME value and the other a DATETIME value. If you transpose data so that both values end up in the same variable then you have a mix of time and datetime values in the variable and which ever format is attempted will display one of the values incorrectly. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/317476"&gt;@knighsson&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your response.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original dataset looks like this:&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 828px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92179i153EFEC21357CC60/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The wanted/new dataset looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 716px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92180iE9E4CF4C79E9DA5B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But I want the "Occ-Time" is still as "DATETIME." format rather than numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 21:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-date-and-time/m-p/910169#M40737</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-02T21:39:43Z</dc:date>
    </item>
  </channel>
</rss>

