<?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 SAS drops zero in front of decimal point if value negative in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952328#M372198</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset of model output from proc mixed that you can see below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.LOC_S;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input Effect:$13. Estimate:D8.4 StdErr:D8.4 DF:BEST4. tValue:7.2 Probt:PVALUE6.4 Alpha:BEST6. Lower:D8.4 Upper:D8.4;&lt;BR /&gt;format Estimate D8.4 StdErr D8.4 DF BEST4. tValue 7.2 Probt PVALUE6.4 Alpha BEST6. Lower D8.4 Upper D8.4;&lt;BR /&gt;label StdErr="Standard Error" tValue="t Value" Probt="Pr &amp;gt; |t|";&lt;BR /&gt;datalines;&lt;BR /&gt;Intercept 6.0372 0.9943 121 6.07 &amp;lt;.0001 0.05 4.0689 8.0056&lt;BR /&gt;locnum 0.9745 0.2117 31.3 4.60 &amp;lt;.0001 0.05 0.5429 1.4060&lt;BR /&gt;visit -0.3080 0.1693 66.3 -1.82 0.0734 0.05 -0.6459 0.03003&lt;BR /&gt;locnum*locnum -0.04245 0.01383 17.5 -3.07 0.0068 0.05 -0.07158 -0.01333&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to combine the estimate and confidence interval into one variable, but when I do so, the leading zero for the negative decimals is lost.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data loc;
 set loc_s;
 Est95CL=put(Estimate,Z5.3)||' ('||compress(put(Lower,Z5.3)||','||put(Upper,Z5.3)||')');
 drop estimate lower upper stderr df tvalue alpha;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And this is what happens:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.LOC;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input Effect:$13. Probt:PVALUE6.4 Est95CL:$19.;&lt;BR /&gt;format Probt PVALUE6.4;&lt;BR /&gt;label Probt="Pr &amp;gt; |t|";&lt;BR /&gt;datalines;&lt;BR /&gt;Intercept &amp;lt;.0001 6.037 (4.069,8.006)&lt;BR /&gt;locnum &amp;lt;.0001 0.974 (0.543,1.406)&lt;BR /&gt;visit 0.0734 -.308 (-.646,0.030)&lt;BR /&gt;locnum*locnum 0.0068 -.042 (-.072,-.013)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to keep the zeros in front of the decimal points for the negative values?&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2024 20:51:14 GMT</pubDate>
    <dc:creator>spidersgeorg</dc:creator>
    <dc:date>2024-12-02T20:51:14Z</dc:date>
    <item>
      <title>SAS drops zero in front of decimal point if value negative</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952328#M372198</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset of model output from proc mixed that you can see below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.LOC_S;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input Effect:$13. Estimate:D8.4 StdErr:D8.4 DF:BEST4. tValue:7.2 Probt:PVALUE6.4 Alpha:BEST6. Lower:D8.4 Upper:D8.4;&lt;BR /&gt;format Estimate D8.4 StdErr D8.4 DF BEST4. tValue 7.2 Probt PVALUE6.4 Alpha BEST6. Lower D8.4 Upper D8.4;&lt;BR /&gt;label StdErr="Standard Error" tValue="t Value" Probt="Pr &amp;gt; |t|";&lt;BR /&gt;datalines;&lt;BR /&gt;Intercept 6.0372 0.9943 121 6.07 &amp;lt;.0001 0.05 4.0689 8.0056&lt;BR /&gt;locnum 0.9745 0.2117 31.3 4.60 &amp;lt;.0001 0.05 0.5429 1.4060&lt;BR /&gt;visit -0.3080 0.1693 66.3 -1.82 0.0734 0.05 -0.6459 0.03003&lt;BR /&gt;locnum*locnum -0.04245 0.01383 17.5 -3.07 0.0068 0.05 -0.07158 -0.01333&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to combine the estimate and confidence interval into one variable, but when I do so, the leading zero for the negative decimals is lost.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data loc;
 set loc_s;
 Est95CL=put(Estimate,Z5.3)||' ('||compress(put(Lower,Z5.3)||','||put(Upper,Z5.3)||')');
 drop estimate lower upper stderr df tvalue alpha;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And this is what happens:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.LOC;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input Effect:$13. Probt:PVALUE6.4 Est95CL:$19.;&lt;BR /&gt;format Probt PVALUE6.4;&lt;BR /&gt;label Probt="Pr &amp;gt; |t|";&lt;BR /&gt;datalines;&lt;BR /&gt;Intercept &amp;lt;.0001 6.037 (4.069,8.006)&lt;BR /&gt;locnum &amp;lt;.0001 0.974 (0.543,1.406)&lt;BR /&gt;visit 0.0734 -.308 (-.646,0.030)&lt;BR /&gt;locnum*locnum 0.0068 -.042 (-.072,-.013)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to keep the zeros in front of the decimal points for the negative values?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 20:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952328#M372198</guid>
      <dc:creator>spidersgeorg</dc:creator>
      <dc:date>2024-12-02T20:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS drops zero in front of decimal point if value negative</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952330#M372200</link>
      <description>&lt;P&gt;You use format Z5.3; with a negative number, you have 3 decimals, 1 decimal point and 1 sign, so SAS drops the leading zero in favor of the sign and keeping the 3 decimals.&lt;/P&gt;
&lt;P&gt;In order to keep the zero, use another format or a larger length.&lt;/P&gt;
&lt;P&gt;What is the range of your numbers, and how do you want them displayed?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 20:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952330#M372200</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-12-02T20:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS drops zero in front of decimal point if value negative</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952332#M372201</link>
      <description>&lt;P&gt;Thanks for your response! I tried using d8.2 and that worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got this output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.LOC;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input Effect:$13. Probt:PVALUE6.4 Est95CL:$28.;&lt;BR /&gt;format Probt PVALUE6.4;&lt;BR /&gt;label Probt="Pr &amp;gt; |t|";&lt;BR /&gt;datalines;&lt;BR /&gt;Intercept &amp;lt;.0001 6.037 (4.069,8.006)&lt;BR /&gt;locnum &amp;lt;.0001 0.974 (0.543,1.406)&lt;BR /&gt;visit 0.0734 -0.308 (-0.646,0.030)&lt;BR /&gt;locnum*locnum 0.0068 -0.042 (-0.072,-0.013)&lt;BR /&gt;;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 20:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952332#M372201</guid>
      <dc:creator>spidersgeorg</dc:creator>
      <dc:date>2024-12-02T20:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS drops zero in front of decimal point if value negative</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952335#M372202</link>
      <description>&lt;P&gt;5 characters does not leave enough room for 3 decimal places, a period, a negative sign and an extra zero.&amp;nbsp;&amp;nbsp;The computer was better at counting than the human, it normally is, so it removed the leading zero so it could fit the result into 5 characters.&lt;/P&gt;
&lt;PRE&gt;2497  data have;
2498    input estimate lower upper ;
2499    list;
2500  cards;

RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
2501        6.037 4.069 8.006
2502        0.974 0.543 1.406
2503        -.308 -.646 0.030
2504        -.042 -.072 -.013
&lt;/PRE&gt;
&lt;P&gt;Use a larger WIDTH on the format.&amp;nbsp; I doubt you want to print values like -000.308 so do not use the Z format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  test1=cat(put(estimate,6.3),' (',put(upper,6.3),',',put(lower,6.3),')');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    estimate     lower     upper            test1

 1       6.037      4.069     8.006     6.037 ( 8.006, 4.069)
 2       0.974      0.543     1.406     0.974 ( 1.406, 0.543)
 3      -0.308     -0.646     0.030    -0.308 ( 0.030,-0.646)
 4      -0.042     -0.072    -0.013    -0.042 (-0.013,-0.072)
&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Dec 2024 21:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952335#M372202</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-12-02T21:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS drops zero in front of decimal point if value negative</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952431#M372237</link>
      <description>&lt;P&gt;This worked thank you!!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 14:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952431#M372237</guid>
      <dc:creator>spidersgeorg</dc:creator>
      <dc:date>2024-12-03T14:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS drops zero in front of decimal point if value negative</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952432#M372238</link>
      <description>&lt;P&gt;increasing the width fixed it, thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 14:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-drops-zero-in-front-of-decimal-point-if-value-negative/m-p/952432#M372238</guid>
      <dc:creator>spidersgeorg</dc:creator>
      <dc:date>2024-12-03T14:22:55Z</dc:date>
    </item>
  </channel>
</rss>

