<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Formatted variables incorrectly outputting to excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatted-variables-incorrectly-outputting-to-excel/m-p/626477#M184796</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm using is as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I'm using Enterprise guide and export with the export button in the Output Data tab to an xlsx.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the xlsx some values are just text as expected, but some have the time as a number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Feb 2020 15:02:58 GMT</pubDate>
    <dc:creator>RoddyJ</dc:creator>
    <dc:date>2020-02-21T15:02:58Z</dc:date>
    <item>
      <title>Formatted variables incorrectly outputting to excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatted-variables-incorrectly-outputting-to-excel/m-p/626477#M184796</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm using is as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I'm using Enterprise guide and export with the export button in the Output Data tab to an xlsx.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the xlsx some values are just text as expected, but some have the time as a number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2020 15:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatted-variables-incorrectly-outputting-to-excel/m-p/626477#M184796</guid>
      <dc:creator>RoddyJ</dc:creator>
      <dc:date>2020-02-21T15:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Formatted variables incorrectly outputting to excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatted-variables-incorrectly-outputting-to-excel/m-p/626480#M184797</link>
      <description>&lt;P&gt;You need to explain more what you mean by "&lt;SPAN&gt;button in the Output Data tab".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;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?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2020 15:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatted-variables-incorrectly-outputting-to-excel/m-p/626480#M184797</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-21T15:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Formatted variables incorrectly outputting to excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatted-variables-incorrectly-outputting-to-excel/m-p/626481#M184798</link>
      <description>Enterprise guide, will update post</description>
      <pubDate>Fri, 21 Feb 2020 15:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatted-variables-incorrectly-outputting-to-excel/m-p/626481#M184798</guid>
      <dc:creator>RoddyJ</dc:creator>
      <dc:date>2020-02-21T15:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Formatted variables incorrectly outputting to excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatted-variables-incorrectly-outputting-to-excel/m-p/626494#M184806</link>
      <description>&lt;P&gt;Show an example of what is wrong.&amp;nbsp; It is not clear what variable you are talking about.&amp;nbsp; You don't show a variable named TIME.&lt;/P&gt;
&lt;P&gt;Your code generates dataset TIME_DIFFS, MEDIAN_DIFFS and DIFF_OUTPUT.&amp;nbsp; Which of these are you exporting?&lt;/P&gt;
&lt;P&gt;Your code mentions variables named T1, T2, DIFF, BY_VAR, and DIFF_TEXT.&amp;nbsp;&amp;nbsp;Which of these are showing properly? Which are not?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2020 16:09:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatted-variables-incorrectly-outputting-to-excel/m-p/626494#M184806</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-21T16:09:34Z</dc:date>
    </item>
  </channel>
</rss>

