<?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: Concatenating means and standard deviations with trailing zeros when needed in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-means-and-standard-deviations-with-trailing-zeros/m-p/975685#M378147</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want; 
    SET carsengine_trp;
    mean_SD = cat(put(mean,12.2),' (',trim(put(std,12.2 -L)),')'); 
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are not required to create values like 3.20 (1.11) because of some government agency requiring it, you would be much better off putting mean and standard deviation in seperate columns, it is much easier, no transpose or concatenation required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are required to produce a lot of tables with this need to create values like 3.20 (1.11), perhaps you should learn the &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030" target="_self"&gt;%TABLEN macro&lt;/A&gt;, which has all of this built in, you don't have to create the code yourself.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Sep 2025 18:32:14 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2025-09-24T18:32:14Z</dc:date>
    <item>
      <title>Concatenating means and standard deviations with trailing zeros when needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-means-and-standard-deviations-with-trailing-zeros/m-p/975683#M378146</link>
      <description>&lt;P&gt;I'm trying to create output for means and standard deviations that can easily be moved into a table. The final output should be in the form 3.20 (1.11). The code I have is pretty close, but it's dropping trailing zeros. The example I just provided actually shows up as 3.2 (1.11). How do I make sure both the mean and the standard deviation have exactly 2 numbers after the decimal point?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found another post that said something about using the format f12.2, but I couldn't get that to work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MEANS data=SAShelp.cars mean stddev;
	var enginesize;
	OUTPUT OUT=carsengine;
	RUN;

PROC TRANSPOSE data = carsengine out = carsengine_trp;
by _TYPE_;
id _STAT_;
var enginesize;
RUN;

DATA want; SET carsengine_trp;
	mean_rd = round(Mean, .01);
	std_rd = round(std, .01);
	/*mean_SD = cat(input(mean_rd f12.2),'(',(std_rd f12.2),')');*/ /*This doesn't work*/
	mean_SD = cat(mean_rd,' (',std_rd,')');
RUN;

PROC PRINT data=want; RUN;&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;</description>
      <pubDate>Wed, 24 Sep 2025 18:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-means-and-standard-deviations-with-trailing-zeros/m-p/975683#M378146</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2025-09-24T18:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating means and standard deviations with trailing zeros when needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-means-and-standard-deviations-with-trailing-zeros/m-p/975685#M378147</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want; 
    SET carsengine_trp;
    mean_SD = cat(put(mean,12.2),' (',trim(put(std,12.2 -L)),')'); 
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are not required to create values like 3.20 (1.11) because of some government agency requiring it, you would be much better off putting mean and standard deviation in seperate columns, it is much easier, no transpose or concatenation required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are required to produce a lot of tables with this need to create values like 3.20 (1.11), perhaps you should learn the &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030" target="_self"&gt;%TABLEN macro&lt;/A&gt;, which has all of this built in, you don't have to create the code yourself.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2025 18:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-means-and-standard-deviations-with-trailing-zeros/m-p/975685#M378147</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-09-24T18:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating means and standard deviations with trailing zeros when needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-means-and-standard-deviations-with-trailing-zeros/m-p/975687#M378149</link>
      <description>&lt;P&gt;Perfect, thanks! Can I ask what the -L option does?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2025 18:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-means-and-standard-deviations-with-trailing-zeros/m-p/975687#M378149</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2025-09-24T18:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating means and standard deviations with trailing zeros when needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-means-and-standard-deviations-with-trailing-zeros/m-p/975688#M378150</link>
      <description>&lt;P&gt;Easy way to find out: try it without -L and you will see.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2025 18:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-means-and-standard-deviations-with-trailing-zeros/m-p/975688#M378150</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-09-24T18:39:47Z</dc:date>
    </item>
  </channel>
</rss>

