I want to display the time for decision_date2 in time format like this I used hhmm8.2 however I get different results in decision_date2. How can I obtain the time format and would it maintain once I exported, especially in ODS whcih is the ultimate output
By any chance do you want the TIMEPART of decision_date for the second value?
Times and Datetimes in SAS are seconds, Dates are days. You will not have much luck displaying DATES with a TIME value.
If you permanently attach a format to a variable that will generally be the default for most output that does not involve a calculation (sas as mean in proc means/summary output for instance). Or specify the format in procedure generating the output such as Proc print. One of the nice things with the SAS formats is the ability to override them as needed.
By the way, one of my pet peeves is calling datetime values a date, or time values a date or dates a time/datetime. While other data systems may not care the measurement differences in SAS make it important. Proper use of functions and or formats requires that understanding. Both values are numeric and numeric functions generally don't care what you give them. Consider:
put y= ;
I declared a TIME variable and them applied a DATE function. What would the result for Y actually mean if it appears in your output?
decision_date2=datepart(decision_date); /* Didn'y you mean: timepart ? */
format decision_date1 mmddyy10.;
put decision_date2 hhmm8.2;
What is the logic of subsetin datepart and displaying it with hhmm format ?
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.