<?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: Create Table SQL,  Round to Tenth, Export to Excel in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/374173#M65277</link>
    <description>&lt;P&gt;If you want to round the results use the ROUND() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select round(sum(C)/sum(D)*100 from have),0.1) as All  
     , ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 08 Jul 2017 14:47:53 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-07-08T14:47:53Z</dc:date>
    <item>
      <title>Create Table SQL,  Round to Tenth, Export to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/373413#M65216</link>
      <description>&lt;PRE&gt;proc sql;
create table want as
select 'A' label='Variable',
 (select sum(A) from have) as All,
 (select sum(A) from have where SCHTYPE='PUBLIC') as Public,
 (select sum(A) from have where SCHTYPE='PRIVATE') as Private
from have(obs=1)
union 
select 'B' label='Variable',
 (select sum(B)from have) as All,
 (select sum(B)from have where SCHTYPE='PUBLIC') as Public,
 (select sum(B)from have where SCHTYPE='PRIVATE') as Private
from have(obs=1)
union
select 'C' label='Variable',
 (select sum(C) from have) as All,
 (select sum(C) from have where SCHTYPE='PUBLIC') as Public,
 (select sum(C) from have where SCHTYPE='PRIVATE') as Private
from have(obs=1)
union 
select 'D' label='Variable',
 (select sum(D)from have) as All,
 (select sum(D)from have where SCHTYPE='PUBLIC') as Public,
 (select sum(D)from have where SCHTYPE='PRIVATE') as Private
from have(obs=1)
union
select 'E' label='Variable',
 (select (sum(A)/sum(B))*100 from have) as All, 
 (select (sum(A)/sum(B))*100 from have where SCHTYPE='PUBLIC') as Public,
 (select (sum(A)/sum(B))*100  from have where SCHTYPE='PRIVATE') as Private
from have(obs=1)
union 
select 'F' label='Variable',
  (select (sum(C)/sum(D)*100 from have) as All,
 (select (sum(C)/sum(D)*100  from have where SCHTYPE='PUBLIC') as Public,
 (select (sum(C)/sum(D)*100  from have where SCHTYPE='PRIVATE') as Private
from have(obs=1)

;
quit;&lt;BR /&gt;
&lt;/PRE&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the code above and want to export the table into&amp;nbsp;Excel&amp;nbsp;with the percentage values for F and G rounded to the tenths. Is it possible to do so?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 19:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/373413#M65216</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-07-05T19:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create Table SQL,  Round to Tenth, Export to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/373424#M65219</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;jcis7 wrote:&amp;nbsp;
&lt;P&gt;I have the code above and want to export the table into&amp;nbsp;Excel&amp;nbsp;with the percentage values for F and G rounded to the tenths. Is it possible to do so?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, it's possible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What exactly is your question?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 19:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/373424#M65219</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-05T19:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create Table SQL,  Round to Tenth, Export to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/373442#M65220</link>
      <description>How do you do it?  Thanks.&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jul 2017 20:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/373442#M65220</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-07-05T20:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create Table SQL,  Round to Tenth, Export to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/373445#M65221</link>
      <description>&lt;P&gt;&lt;A href="http://blogs.sas.com/content/sasdummy/2012/02/11/export-excel-methods/" target="_blank"&gt;http://blogs.sas.com/content/sasdummy/2012/02/11/export-excel-methods/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the percents, apply a PERCENT format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select 'A' label='Variable',
 (select sum(A) from have) as All,
 (select sum(A) from have where SCHTYPE='PUBLIC') as Public format=percent8.1,
 (select sum(A) from have where SCHTYPE='PRIVATE') as Private format=percent8.1
from have(obs=1)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 21:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/373445#M65221</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-05T21:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create Table SQL,  Round to Tenth, Export to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/374053#M65265</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; The formatting doesn't stay when the table is exported.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2017 18:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/374053#M65265</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-07-07T18:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create Table SQL,  Round to Tenth, Export to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/374055#M65266</link>
      <description>&lt;P&gt;That depends on how you export it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use ODS EXCEL to maintain the formats.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or use PUT to convert the data to a character variable with the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char_var = put(old_var, percent8.1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jul 2017 18:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/374055#M65266</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-07T18:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create Table SQL,  Round to Tenth, Export to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/374173#M65277</link>
      <description>&lt;P&gt;If you want to round the results use the ROUND() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select round(sum(C)/sum(D)*100 from have),0.1) as All  
     , ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Jul 2017 14:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/374173#M65277</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-08T14:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create Table SQL,  Round to Tenth, Export to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/374198#M65279</link>
      <description>&lt;P&gt;Please clarify: do you want to maintain your data at full precision but just display the values as rounded, or do you want to actually round the data as stored? If it's the latter then use&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s solution.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jul 2017 22:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/374198#M65279</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-07-08T22:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create Table SQL,  Round to Tenth, Export to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/443562#M69346</link>
      <description>&lt;P&gt;Thank you everyone!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Two questions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just need the value rounded to the tenth exported&amp;nbsp;into an excel worksheet.&amp;nbsp; I tried Tom's code and got the following error when I used the following code.&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp; What am I doing wrong?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; What does (obs=1) do?&lt;/P&gt;
&lt;P&gt;Any help you can give will be most appreciated.&amp;nbsp; Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table want as
select 'C.' label='A-G',
  (select round(sum(A)/sum(F) from a.have),0.1) as All, 
 (select round(sum(A)/sum(F)   from a.have),0.1) where pub_priv='PUBLIC') as Public,
 (select round(sum(A)/sum(F)   from a.have),0.1) where pub_priv='PRIVATE') as Private
from a.have(obs=1);
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;771&lt;/P&gt;
&lt;P&gt;772 proc sql;&lt;/P&gt;
&lt;P&gt;773 create table&amp;nbsp;want as&lt;/P&gt;
&lt;P&gt;786 select 'C. label='A-G',&lt;/P&gt;
&lt;P&gt;787 (select round(sum(A)/sum(F) from a.have),0.1) as All,&lt;/P&gt;
&lt;P&gt;---- -&lt;/P&gt;
&lt;P&gt;22 76&lt;/P&gt;
&lt;P&gt;202&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, ), *, **, +, ',', -, /, &amp;lt;,&lt;/P&gt;
&lt;P&gt;&amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE,&lt;/P&gt;
&lt;P&gt;LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;787! (select round(sum(A)/sum(F) from a.have),0.1) as All,&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;22&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, !, !!, &amp;amp;, *, **, +,&lt;/P&gt;
&lt;P&gt;',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, AS, BETWEEN, CONTAINS, EQ, EQT, FORMAT, FROM,&lt;/P&gt;
&lt;P&gt;GE, GET, GT, GTT, IN, INFORMAT, INTO, IS, LABEL, LE, LEN, LENGTH, LET, LIKE, LT, LTT,&lt;/P&gt;
&lt;P&gt;NE, NET, NOT, NOTIN, OR, TRANSCODE, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;
&lt;P&gt;788 (select round(sum(A)/sum(F) from a.have),0.1) where pub_priv='PUBLIC') as&lt;/P&gt;
&lt;P&gt;788! Public,&lt;/P&gt;
&lt;P&gt;789 (select round(sum(A)/sum(F) from a.have),0.1) where pub_priv='PRIVATE') as&lt;/P&gt;
&lt;P&gt;789! Private&lt;/P&gt;
&lt;P&gt;790 from a.have(obs=1);&lt;/P&gt;
&lt;P&gt;791 quit;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;
&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;
&lt;P&gt;real time 0.00 seconds&lt;/P&gt;
&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 23:57:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/443562#M69346</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2018-03-07T23:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create Table SQL,  Round to Tenth, Export to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/443812#M69352</link>
      <description>&lt;P&gt;You need to add a n after the first name. Which is why there's a best practice to not allow spaces and symbols in the name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select 'C.'n label='A-G',&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Mar 2018 16:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-Table-SQL-Round-to-Tenth-Export-to-Excel/m-p/443812#M69352</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-08T16:24:12Z</dc:date>
    </item>
  </channel>
</rss>

