<?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 Re: PROC EXPORT AND FORMAT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244288#M45505</link>
    <description>&lt;P&gt;I do not realize there are two options. idealy, I would be happy to learn both two options.&lt;/P&gt;&lt;P&gt;My priority is the last one, "have the value 2.8 directly"/&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jan 2016 20:13:09 GMT</pubDate>
    <dc:creator>Bal23</dc:creator>
    <dc:date>2016-01-18T20:13:09Z</dc:date>
    <item>
      <title>PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244258#M45490</link>
      <description>&lt;P&gt;If I want to generate an excel file, I want to use fomat funtion so that it can format a decimal correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is, if it originally generates a number like, 2.89888555, I want it be like, 2.90, or 2.9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;outfile = "c:\tables"&lt;BR /&gt;dbms = XLSX replace;&lt;BR /&gt;can I use format to do that? Any other options?&lt;BR /&gt;------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 17:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244258#M45490</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-18T17:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244263#M45494</link>
      <description>&lt;P&gt;&lt;SPAN&gt;can I use format to do that? - Yes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any other options? - No, not with PROC EXPORT.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 18:28:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244263#M45494</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-01-18T18:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244264#M45495</link>
      <description>&lt;P&gt;In any case I would recommend to export the exact value to Excel and then use Excel functionality (possibly controlled by SAS) to display the value rounded to 1 or 2 decimals. This would avoid unnecessary rounding issues if people work with the Excel file you created, perform calculations, filter data (e.g. "all values &amp;lt;2.9"), etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if you can trigger the Excel formatting by PROC EXPORT or if you should better use ODS, as I don't have that SAS/ACCESS license. If it's not possible, but you still want to use PROC EXPORT and do the formatting (almost) automatically,&amp;nbsp;you could record/write an Excel (VBA) macro to&amp;nbsp;achieve this.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 18:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244264#M45495</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-01-18T18:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244266#M45496</link>
      <description>&lt;P&gt;Would you please show me a sample excel macro code? Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 18:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244266#M45496</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-18T18:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244273#M45497</link>
      <description>&lt;P&gt;What version of SAS do you have?&lt;/P&gt;
&lt;P&gt;How big is the dataset?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 19:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244273#M45497</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-18T19:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244274#M45498</link>
      <description>&lt;P&gt;I didn't have such a macro on my computer, but I quickly created one by using Excel's user-friendly "Record Macro" function (please see Excel help for more [Excel version-specific] details, if necessary). After removing obviously unnecessary lines it looks as simple as this:&lt;/P&gt;
&lt;PRE&gt;Sub twodec()
    Range("A1:A10").Select
    Selection.NumberFormat = "0.00"
End Sub&lt;/PRE&gt;
&lt;P&gt;As you can guess, it selects cell range A1:A10 and applies the number format with two decimals to these 10 cells. It's easy to apply a macro like this to any existing Excel sheet. (To learn how, you probably won't need the&amp;nbsp;Excel help, because it's so intuitive.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to mention SAS (as this is mandatory in this forum): In a recent project of mine I used SAS programs which created (meta-)data-driven VBA macros (for MS Word in that case) and executed them via an X command (calling winword.exe). So, it's possible to let SAS trigger the entire automation, but let the VBA engine do the actual formatting or whatever needs to be done with the MS Office files.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 19:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244274#M45498</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-01-18T19:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244278#M45499</link>
      <description>&lt;P&gt;Proc Export does not support writing of formats to Excel files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before going down the excel macro route you have a couple of other options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Round actual data and present that, although the underlying data is nice, it's not always required.&lt;/P&gt;
&lt;P&gt;2. Using Tagsets.ExcelXP to output an XML file which can be viewed in Excel. This file can then be saved as a native Excel file. There is also a VB script to convert said files to native Excel files automatically if you're interested.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/rnd/base/ods/odsmarkup/excelxp_demo.html" target="_blank"&gt;http://support.sas.com/rnd/base/ods/odsmarkup/excelxp_demo.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;3. Use ODS Excel if you have the latest SAS release&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/sasdummy/2014/08/29/experimenting-with-ods-excel-to-create-spreadsheets-from-sas/" target="_blank"&gt;http://blogs.sas.com/content/sasdummy/2014/08/29/experimenting-with-ods-excel-to-create-spreadsheets-from-sas/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;4. Use a macro written by some power users that generates the native excel file and allows you to choose if formatting is applied or not. &amp;nbsp;This works well, but you have to understand how to call a SAS macro, which is a small learning curve though.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export" target="_blank"&gt;http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 19:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244278#M45499</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-18T19:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244283#M45501</link>
      <description>&lt;P&gt;Thank you. This is a little hard for me to understand&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 19:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244283#M45501</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-18T19:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244284#M45502</link>
      <description>&lt;P&gt;SAS 9.4&lt;/P&gt;&lt;P&gt;it has over 100000 obs&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 19:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244284#M45502</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-18T19:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244285#M45503</link>
      <description>&lt;P&gt;which one is the easiest one&lt;/P&gt;&lt;P&gt;I realize the macro not be the easy one to work on.&lt;/P&gt;&lt;P&gt;For the Tagsets.ExcelXP, I read a little bit but still do not get what I need. I only need the option to change the number from "2.377777"&amp;nbsp; to "2.38" or "2.3" or "2"&lt;/P&gt;&lt;P&gt;so it seems to be irrelevant for me&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 20:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244285#M45503</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-18T20:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244286#M45504</link>
      <description>&lt;P&gt;Do you need to provide underlying data or just the rounded data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ie Does the value in Excel need to be 2.7777 and displayed as 2.8&lt;/P&gt;
&lt;P&gt;or can the cell have the value 2.8 directly.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 20:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244286#M45504</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-18T20:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244288#M45505</link>
      <description>&lt;P&gt;I do not realize there are two options. idealy, I would be happy to learn both two options.&lt;/P&gt;&lt;P&gt;My priority is the last one, "have the value 2.8 directly"/&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 20:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244288#M45505</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-18T20:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244290#M45507</link>
      <description>&lt;P&gt;For the second option then, round the data using the ROUND() function and then use Proc Export.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
set sashelp.class;
weight=round(weight, 0.1);
height=round(height, 0.1);
run;
&amp;nbsp;
proc export data=class outfile='/folders/myfolders/sample.xlsx' dbms=xlsx replace; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 20:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244290#M45507</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-18T20:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244293#M45509</link>
      <description>&lt;P&gt;Thank you very much. This works. How about the first option you mentioned,&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 20:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244293#M45509</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-18T20:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244296#M45510</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods tagsets.excelxp file='C:/_localdata/temp.xml' style=meadow;

proc report data=sashelp.classfit nowd;
column name age sex weight height predict;
define name/display;
define age/display;
define sex/display;
define weight/display;
define height/display;
define predict/style={tagattr='format:####.0'};
run;quit;


ods tagsets.excelxp close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;The Tagsets link I originally included has demo code showing the various features of Tagsets destination. As mentioned this does not generate a native XLSX file, but you can open it with excel or use the VBS &amp;nbsp;to convert it to XLSX automatically.&lt;/P&gt;
&lt;P&gt;If you're interested in that please read the following SAS Sample, there is code under the Download tab.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/43/496.html" target="_blank"&gt;http://support.sas.com/kb/43/496.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have SAS 9.4 you can try changing the destination to ODS EXCEL and see if it generates a native excel file successfully. I don't have SAS 9.4 to test on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 20:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244296#M45510</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-18T20:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244480#M45564</link>
      <description>&lt;P&gt;Thank you. I did try this option. The problem is, the result is generated automatically omited 0 infront.&lt;/P&gt;&lt;P&gt;that is I want it shows as "0.97" but it shows ".97"&lt;/P&gt;&lt;P&gt;can it be fixed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 16:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244480#M45564</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-19T16:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244496#M45565</link>
      <description>Figure out the Excel format you need and put it in the tagattr , ie 0####.0. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Jan 2016 17:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244496#M45565</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-19T17:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT AND FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244497#M45566</link>
      <description>&lt;P&gt;Thanks. It works!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 17:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-AND-FORMAT/m-p/244497#M45566</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-19T17:34:08Z</dc:date>
    </item>
  </channel>
</rss>

