<?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 Formating output display results in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521719#M4269</link>
    <description>&lt;P&gt;How can I display my output results with commas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let one_hummingbird = 3.5; /* grams */
%let elephant_weight = 8800; /* pounds */

%let pound_birds = %sysfunc(floor(%sysevalf((16*28.3495231)/&amp;amp;one_hummingbird.)));
/* average hummingbirds weight is 3 to 4 grams 
   28.3495231 grams = 1 ounce
   16 ounces to 1 pound
   so 453.59237 grams = 1 pound
   129 hummingbirds to lift 1 pound where the birds weight is 3.5 grams
    and the hummingbird can lift it's self plus it's weight again
   
   African elephants weigh between 4,000-7,000 kg (8,800-15,400 lb).
   Asian elephants weigh between 3,000-5,000 kg (6,600-11,000 lb).
 
*/
%let num_birds_needed = %sysfunc(floor(%sysevalf( 453.59237/&amp;amp;one_hummingbird.*&amp;amp;elephant_weight.)));

data have;
sentence = "With an elephant that weights &amp;amp;elephant_weight. pounds 
     and hummingbirds able to carry an additional &amp;amp;one_hummingbird. grams, 
     then you need &amp;amp;num_birds_needed. hummingbirds.";
run;

proc print data=have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE class="table"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;sentence&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="data"&gt;With an elephant that weights 8800 pounds and hummingbirds able to carry an additional 3.5 grams, then you need 1140460 hummingbirds.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 15 Dec 2018 16:10:12 GMT</pubDate>
    <dc:creator>VDD</dc:creator>
    <dc:date>2018-12-15T16:10:12Z</dc:date>
    <item>
      <title>Formating output display results</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521719#M4269</link>
      <description>&lt;P&gt;How can I display my output results with commas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let one_hummingbird = 3.5; /* grams */
%let elephant_weight = 8800; /* pounds */

%let pound_birds = %sysfunc(floor(%sysevalf((16*28.3495231)/&amp;amp;one_hummingbird.)));
/* average hummingbirds weight is 3 to 4 grams 
   28.3495231 grams = 1 ounce
   16 ounces to 1 pound
   so 453.59237 grams = 1 pound
   129 hummingbirds to lift 1 pound where the birds weight is 3.5 grams
    and the hummingbird can lift it's self plus it's weight again
   
   African elephants weigh between 4,000-7,000 kg (8,800-15,400 lb).
   Asian elephants weigh between 3,000-5,000 kg (6,600-11,000 lb).
 
*/
%let num_birds_needed = %sysfunc(floor(%sysevalf( 453.59237/&amp;amp;one_hummingbird.*&amp;amp;elephant_weight.)));

data have;
sentence = "With an elephant that weights &amp;amp;elephant_weight. pounds 
     and hummingbirds able to carry an additional &amp;amp;one_hummingbird. grams, 
     then you need &amp;amp;num_birds_needed. hummingbirds.";
run;

proc print data=have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE class="table"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;sentence&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="data"&gt;With an elephant that weights 8800 pounds and hummingbirds able to carry an additional 3.5 grams, then you need 1140460 hummingbirds.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Dec 2018 16:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521719#M4269</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-12-15T16:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Formating output display results</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521724#M4270</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How can I display my output results with commas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE class="table"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;sentence&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="data"&gt;With an elephant that weights 8800 pounds and hummingbirds able to carry an additional 3.5 grams, then you need 1140460 hummingbirds.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It seems like your output does have a comma, so I'm not understanding the problem.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Dec 2018 16:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521724#M4270</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-12-15T16:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Formating output display results</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521729#M4272</link>
      <description>&lt;P&gt;the results for the 3 macros are numeric and need comma's for readability.&lt;/P&gt;
&lt;P&gt;8800 pounds should need to be displayed as 8,800 pounds.&amp;nbsp; The same of the number of birds.&amp;nbsp; Where 1140460 needs to display as 1,140,460.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Dec 2018 17:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521729#M4272</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-12-15T17:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Formating output display results</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521732#M4273</link>
      <description>&lt;P&gt;Using comma10. format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let num_birds_needed = %sysfunc(floor(%sysevalf( 453.59237/&amp;amp;one_hummingbird.*&amp;amp;elephant_weight.)),comma10.);
%put &amp;amp;num_birds_needed;&lt;/CODE&gt;&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;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let one_hummingbird = 3.5; /* grams */
%let elephant_weight = 8800; /* pounds */

%let pound_birds = %sysfunc(floor(%sysevalf((16*28.3495231)/&amp;amp;one_hummingbird.)),comma10.);
%put &amp;amp;pound_birds;
/* average hummingbirds weight is 3 to 4 grams 
   28.3495231 grams = 1 ounce
   16 ounces to 1 pound
   so 453.59237 grams = 1 pound
   129 hummingbirds to lift 1 pound where the birds weight is 3.5 grams
    and the hummingbird can lift it's self plus it's weight again
   
   African elephants weigh between 4,000-7,000 kg (8,800-15,400 lb).
   Asian elephants weigh between 3,000-5,000 kg (6,600-11,000 lb).
 
*/
%let num_birds_needed = %sysfunc(floor(%sysevalf( 453.59237/&amp;amp;one_hummingbird.*&amp;amp;elephant_weight.)),comma10.);
%put &amp;amp;num_birds_needed;

data have;
sentence = "With an elephant that weights &amp;amp;elephant_weight. pounds 
     and hummingbirds able to carry an additional &amp;amp;one_hummingbird. grams, 
     then you need &amp;amp;num_birds_needed. hummingbirds.";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Dec 2018 18:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521732#M4273</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-15T18:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Formating output display results</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521734#M4274</link>
      <description>&lt;P&gt;thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; that works.&amp;nbsp; I see that the formatting needed to be done in the assignment statement of the %let.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Dec 2018 18:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521734#M4274</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-12-15T18:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Formating output display results</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521751#M4276</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I see that the formatting needed to be done in the assignment statement of the %let.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The formatting can be done in the %LET statement. It can also be done inside the line that begins with SENTENCE= .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or this whole thing might be done easier in a DATA _NULL_ step rather than using macro variables.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2018 01:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/521751#M4276</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-12-16T01:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Formating output display results</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/522032#M4339</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I see that the formatting needed to be done in the assignment statement of the %let.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The formatting can be done in the %LET statement. It can also be done inside the line that begins with SENTENCE= .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or this whole thing might be done easier in a DATA _NULL_ step rather than using macro variables.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Old school without creating a long variable:&lt;/P&gt;
&lt;PRE&gt;data _null_;
   elephant_weight= 8800;
   one_hummingbird = 3.5;
   num_birds_needed =(453.59237/one_hummingbird) * elephant_weight;
   put "With an elephant that weighs"+1 elephant_weight comma5. +1"pounds and hummingbirds
 able to carry an additional"+1 one_hummingbird +1"grams, then you need" +1 num_birds_needed comma10.
 +1 "hummingbirds.";
run;&lt;/PRE&gt;
&lt;P&gt;Or building the string with a concatenation function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
   elephant_weight= 8800;
   one_hummingbird = 3.5;
   num_birds_needed =(453.59237/one_hummingbird) * elephant_weight;
   string = catx(' ',"With an elephant that weighs",put(elephant_weight, comma5.),"pounds and hummingbirds
 able to carry an additional",one_hummingbird,"grams, then you need",put(num_birds_needed, comma10.),
"hummingbirds.");
   put string;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Dec 2018 20:10:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Formating-output-display-results/m-p/522032#M4339</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-17T20:10:31Z</dc:date>
    </item>
  </channel>
</rss>

