Help using Base SAS procedures

Using datetime variable in proc report

Reply
N/A
Posts: 0

Using datetime variable in proc report

Hello,

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.

Here is the code I have:
proc report data=shona.oos nowindows ;
column jtmdtid date time2 ;

define date/computed format=date9. "Date";
define time2/computed format=time8. "Time";
define jtmdtid/display "";

compute date;
date=datepart(jtmdtid);
endcomp;
compute time2;
time2=timepart(jtmdtid);
endcomp;
run;

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.

Any help is much appreciated.
N/A
Posts: 0

Re: Using datetime variable in proc report

In PROC REPORT
Define the column for display twice.
First with format DTdate.
Second, with format DTtime.

Good Luck

PeterC
N/A
Posts: 0

Re: Using datetime variable in proc report

To things can be done.

1) use "nodisplay" -- that is, read more of the documentation for Proc Report.

2) use dtdate. and dttime. formats -- that is, read more of the documentation for SAS's formats.

SAS documentation is available at http://support.sas.com/documentation/
N/A
Posts: 0

Re: Using datetime variable in proc report

Thanks for your help Peter and Chuck.

The dtdate format worked ok but for dttime it has the following error.

ERROR: The format DTTIME was not found or could not be loaded

I can't find anything in the documentation either when I do a search for dttime which is very odd.
N/A
Posts: 0

Re: Using datetime variable in proc report

sorry that I assumed without checking, that DTtime format would exist.

TOD. provides hh:mm:ss from a datetime value, so hopefully that will do better.

PeterC
N/A
Posts: 0

Re: Using datetime variable in proc report

Ditto
N/A
Posts: 0

Re: Using datetime variable in proc report

tod. works.


Thanks a lot!!!
Ask a Question
Discussion stats
  • 6 replies
  • 146 views
  • 0 likes
  • 1 in conversation