<?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 values in proc report in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Datetime-values-in-proc-report/m-p/20492#M3779</link>
    <description>Hi:&lt;BR /&gt;
  If all you want are these simple formats for your date/time value, then you do not need to calculate those values in a compute block. You can do this with PROC REPORT:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data mystuff;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input name $ bday : datetime18.;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
alan 15nov1950:07:53:45&lt;BR /&gt;
bob  11oct1960:15:23:17&lt;BR /&gt;
carl 23aug1958:10:18:34&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
      &lt;BR /&gt;
proc report data=mystuff nowd;&lt;BR /&gt;
  column name bday bday=time;&lt;BR /&gt;
  define name / display 'Name';&lt;BR /&gt;
  define bday / 'Birth Date' display f=dtdate9.;&lt;BR /&gt;
  define time / 'Birth Time' display f=tod10.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
                      &lt;BR /&gt;
And you will get this output in the LISTING window:&lt;BR /&gt;
[pre]&lt;BR /&gt;
                Birth&lt;BR /&gt;
  Name           Date  Birth Time&lt;BR /&gt;
  alan      15NOV1950    07:53:45&lt;BR /&gt;
  bob       11OCT1960    15:23:17&lt;BR /&gt;
  carl      23AUG1958    10:18:34&lt;BR /&gt;
                          &lt;BR /&gt;
[/pre]                                  &lt;BR /&gt;
                                        &lt;BR /&gt;
PROC REPORT allows the use of "aliases" in the COLUMN statement. So on this report, you would use the BDAY variable two times on the report row. The first time BDAY appears in the COLUMN statement, it appears with its own variable name. That means that the second time BDAY appears in the COLUMN statement, you are telling PROC REPORT that you need to use it a second time on the report row. To have a single variable appear more than one time on a report row, however, PROC REPORT expects that you will provide an ALIAS for the second (or third or fourth) usage. That's what the BDAY=TIME means in the COLUMN staement. So the first BDAY will be formatted using the DTDATE9. format (which will format only the DATE portion of a date/time variable value) and then the report item called TIME, (which is just an alias for BDAY) will be formatted with the TOD10. format.&lt;BR /&gt;
&lt;BR /&gt;
It is only if you wanted OTHER date formats for BDAY that you would need to calculate a new column and use a COMPUTE block. An example of that code (but not the output is below).&lt;BR /&gt;
   &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc report data=mystuff nowd;&lt;BR /&gt;
  column name bday calcdate bday=time ;&lt;BR /&gt;
  define name / display;&lt;BR /&gt;
  define bday / display noprint;&lt;BR /&gt;
  define calcdate /computed f=mmddyy10.;&lt;BR /&gt;
  define time / 'Birth Time' display f=tod10.;&lt;BR /&gt;
  compute calcdate;&lt;BR /&gt;
    calcdate = datepart(bday);&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Fri, 23 May 2008 23:15:07 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2008-05-23T23:15:07Z</dc:date>
    <item>
      <title>Datetime values in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Datetime-values-in-proc-report/m-p/20491#M3778</link>
      <description>Just realised I posted this in the wrong forum previously, I think it should go in this one...&lt;BR /&gt;
&lt;BR /&gt;
Hello,&lt;BR /&gt;
&lt;BR /&gt;
I want to show a datetime variable as two seperate columns for date and time using proc report. This can be done quite simply by adding another datastep before I do the proc report but this is too inefficient for large datasets.&lt;BR /&gt;
&lt;BR /&gt;
Here is the code I have:&lt;BR /&gt;
proc report data=shona.oos nowindows ;&lt;BR /&gt;
column jtmdtid date time2 ;&lt;BR /&gt;
&lt;BR /&gt;
define date/computed format=date9. "Date";&lt;BR /&gt;
define time2/computed format=time8. "Time";&lt;BR /&gt;
define jtmdtid/display "";&lt;BR /&gt;
&lt;BR /&gt;
compute date;&lt;BR /&gt;
date=datepart(jtmdtid);&lt;BR /&gt;
endcomp;&lt;BR /&gt;
compute time2;&lt;BR /&gt;
time2=timepart(jtmdtid);&lt;BR /&gt;
endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
But the problem is the compute blocks won't work unless I have variable jtmdtid in the column part. If I do that then the datetime variable is displayed in the report. I either a completely different way of converting datetime to date and time or else a way of hiding a variable that is specified as a column.&lt;BR /&gt;
&lt;BR /&gt;
Any help is much appreciated.</description>
      <pubDate>Fri, 23 May 2008 09:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Datetime-values-in-proc-report/m-p/20491#M3778</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-23T09:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime values in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Datetime-values-in-proc-report/m-p/20492#M3779</link>
      <description>Hi:&lt;BR /&gt;
  If all you want are these simple formats for your date/time value, then you do not need to calculate those values in a compute block. You can do this with PROC REPORT:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data mystuff;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input name $ bday : datetime18.;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
alan 15nov1950:07:53:45&lt;BR /&gt;
bob  11oct1960:15:23:17&lt;BR /&gt;
carl 23aug1958:10:18:34&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
      &lt;BR /&gt;
proc report data=mystuff nowd;&lt;BR /&gt;
  column name bday bday=time;&lt;BR /&gt;
  define name / display 'Name';&lt;BR /&gt;
  define bday / 'Birth Date' display f=dtdate9.;&lt;BR /&gt;
  define time / 'Birth Time' display f=tod10.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
                      &lt;BR /&gt;
And you will get this output in the LISTING window:&lt;BR /&gt;
[pre]&lt;BR /&gt;
                Birth&lt;BR /&gt;
  Name           Date  Birth Time&lt;BR /&gt;
  alan      15NOV1950    07:53:45&lt;BR /&gt;
  bob       11OCT1960    15:23:17&lt;BR /&gt;
  carl      23AUG1958    10:18:34&lt;BR /&gt;
                          &lt;BR /&gt;
[/pre]                                  &lt;BR /&gt;
                                        &lt;BR /&gt;
PROC REPORT allows the use of "aliases" in the COLUMN statement. So on this report, you would use the BDAY variable two times on the report row. The first time BDAY appears in the COLUMN statement, it appears with its own variable name. That means that the second time BDAY appears in the COLUMN statement, you are telling PROC REPORT that you need to use it a second time on the report row. To have a single variable appear more than one time on a report row, however, PROC REPORT expects that you will provide an ALIAS for the second (or third or fourth) usage. That's what the BDAY=TIME means in the COLUMN staement. So the first BDAY will be formatted using the DTDATE9. format (which will format only the DATE portion of a date/time variable value) and then the report item called TIME, (which is just an alias for BDAY) will be formatted with the TOD10. format.&lt;BR /&gt;
&lt;BR /&gt;
It is only if you wanted OTHER date formats for BDAY that you would need to calculate a new column and use a COMPUTE block. An example of that code (but not the output is below).&lt;BR /&gt;
   &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc report data=mystuff nowd;&lt;BR /&gt;
  column name bday calcdate bday=time ;&lt;BR /&gt;
  define name / display;&lt;BR /&gt;
  define bday / display noprint;&lt;BR /&gt;
  define calcdate /computed f=mmddyy10.;&lt;BR /&gt;
  define time / 'Birth Time' display f=tod10.;&lt;BR /&gt;
  compute calcdate;&lt;BR /&gt;
    calcdate = datepart(bday);&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 23 May 2008 23:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Datetime-values-in-proc-report/m-p/20492#M3779</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-05-23T23:15:07Z</dc:date>
    </item>
  </channel>
</rss>

