BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
6 REPLIES 6
deleted_user
Not applicable
In PROC REPORT
Define the column for display twice.
First with format DTdate.
Second, with format DTtime.

Good Luck

PeterC
deleted_user
Not applicable
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/
deleted_user
Not applicable
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.
deleted_user
Not applicable
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
deleted_user
Not applicable
tod. works.


Thanks a lot!!!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2484 views
  • 1 like
  • 1 in conversation