- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 05-23-2008 05:32 AM
(2480 views)
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.
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.
6 REPLIES 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In PROC REPORT
Define the column for display twice.
First with format DTdate.
Second, with format DTtime.
Good Luck
PeterC
Define the column for display twice.
First with format DTdate.
Second, with format DTtime.
Good Luck
PeterC
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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/
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
TOD. provides hh:mm:ss from a datetime value, so hopefully that will do better.
PeterC
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ditto
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
tod. works.
Thanks a lot!!!
Thanks a lot!!!