Hi all,
I've calculated a time difference between two datetime variables in a dataset. When I try to export it Excel, the format of the time difference are incorrect and inconsistent. I'd like them to be output in HH:MM format.
The code I'm using is as follows:
data time_diffs;
set times;
diff = t1 - t2;
/* format diff hhmm. */
run;
proc means;
class by_var;
var diff;
output out=median_diffs median(diff)=diff;
run;
data diffs_output;
set median_diffs
diff_text = put(diff, hhmm.);
run;I'm using Enterprise guide and export with the export button in the Output Data tab to an xlsx.
In the xlsx some values are just text as expected, but some have the time as a number.
Can anyone help?
You need to explain more what you mean by "button in the Output Data tab".
First how are you running your SAS code? Sounds like you are using some type of point and click interface. Which one? Enterprise Guide? SAS/Studio? Something else?
Show an example of what is wrong. It is not clear what variable you are talking about. You don't show a variable named TIME.
Your code generates dataset TIME_DIFFS, MEDIAN_DIFFS and DIFF_OUTPUT. Which of these are you exporting?
Your code mentions variables named T1, T2, DIFF, BY_VAR, and DIFF_TEXT. Which of these are showing properly? Which are not?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.