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!!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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