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?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: