<?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 MEANS and PROC UNIVARIATE producing different results for summary statistics in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410986#M100451</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154641"&gt;@arg1&lt;/a&gt;&amp;nbsp;I agree. I think this is an artifact of the very small data and don't think the difference is significant. The values are the same, and I understand why you want confirmation though, and I think the next step would be SAS Tech Support.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you test it with a larger data set then it works fully as expected - the HEX and BASE values included. I think it's Excel that you can actually get it to return a negative variance - which isn't possible - but requires small N.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test ;
set sashelp.class;
value=weight;
	;
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 06 Nov 2017 20:30:51 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-11-06T20:30:51Z</dc:date>
    <item>
      <title>PROC MEANS and PROC UNIVARIATE producing different results for summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410971#M100442</link>
      <description>&lt;P&gt;My collegue and I are calculating summary statistics using two different methods.&amp;nbsp; We don't understand why the results of BASE_VALUE are not the same.&amp;nbsp; Both procedures present the standard deviation 0.005 but after performing the the put function below, the PROC MEANS &lt;SPAN&gt;StDev&amp;nbsp;&lt;/SPAN&gt;= 0.01 while PROC UNIVARIATE StDev = 0.00.&amp;nbsp; I have determined that the Hex Values are not the same but I don't know why or which value is more correct.&amp;nbsp; Any help or insight is much appreciated!&amp;nbsp; Thanks!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;strip(PUT(COL1,8.2))&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;data test ;
	INPUT VALUE 8. ;
	DATALINES ;
0.12
0.12
0.12
0.11
	;
RUN ;
&lt;BR /&gt;* Proc Means ;
proc means data = test noprint ;
	var VALUE ;	
	output out = proc_mean mean = MeanS std = StdDevS min = MinS max = MaxS n = nS median = MedianS ;
run ;
&lt;BR /&gt;* Proc univariate ;
proc univariate data = test noprint ;
	var VALUE ;	
	output out = proc_univ mean = MeanS std = StdDevS min = MinS max = MaxS n = nS median = MedianS ;
run ;
&lt;BR /&gt;* Transpose both ;
proc transpose data = proc_mean out= proc_mean2 ; run ;
proc transpose data = proc_univ out= proc_univ2 ; run ;
&lt;BR /&gt;* Proc means data - Round to 2dp, determine hex value, and print ;
data proc_mean2 ;
	set proc_mean2 ;
	if _NAME_ in('STDDEVS') then do;
		BASE_VALUE = strip(PUT(COL1,8.2)) ;
		HEX_VALUE = put(COL1,HEX16.) ;
	end ;
	proc print ;
	var _NAME_ COL1 BASE_VALUE HEX_VALUE ;
	WHERE _NAME_ = 'STDDEVS' ;
RUN ;

* Proc univariate data- Round to 2dp, determine Hex value, and print ;
data proc_univ2 ;
	set proc_univ2 ;
	if _NAME_ in('STDDEVS') then do;
		BASE_VALUE = strip(PUT(COL1,8.2)) ;
		HEX_VALUE = put(COL1,HEX16.) ;
	end ;
	proc print ;
	var _NAME_ COL1 BASE_VALUE HEX_VALUE ;
	WHERE _NAME_ = 'STDDEVS' ;
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 376px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16479iF0D96C4978CDE4F9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410971#M100442</guid>
      <dc:creator>arg1</dc:creator>
      <dc:date>2017-11-06T20:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: PROC MEANS and PROC UNIVARIATE producing different results for summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410974#M100443</link>
      <description>&lt;P&gt;Instead of PUT use ROUND().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get the same results for the HEX values, but the Base values are the same.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that I had to change some of your code to get this to run properly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS. It helps if you add comments to your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test ;
	INPUT VALUE 8. ;
	DATALINES ;
0.12
0.12
0.12
0.11
	;
RUN ;

proc means data = test noprint ;
	var VALUE ;	
	output out = proc_mean mean = MeanS std = StdDevS min = MinS max = MaxS n = nS median = MedianS ;
run ;

proc univariate data = test noprint ;
	var VALUE ;	
	output out = proc_univ mean = MeanS std = StdDevS min = MinS max = MaxS n = nS median = MedianS ;
run ;

proc transpose data = proc_mean out= proc_mean2 ; run ;
proc transpose data = proc_univ out= proc_univ2 ; run ;

data proc_mean3 ;
	set proc_mean2 ;
	if _NAME_ in('StdDevS') then do;
		BASE_VALUE = strip(put(round(COL1,0.01), 8.2)) ;
		HEX_VALUE = put(COL1,HEX16.) ;
	end ;
	proc print data=proc_mean3;
	var _NAME_ COL1 BASE_VALUE HEX_VALUE ;
	WHERE _NAME_ = 'StdDevS' ;
RUN ;


data proc_univ2 ;
	set proc_univ2 ;
	if _NAME_ in('StdDevS') then do;
		BASE_VALUE = strip(put(round(COL1, 0.01), 8.2)) ;
		HEX_VALUE = put(COL1,HEX16.) ;
	end ;
	proc print ;
	var _NAME_ COL1 BASE_VALUE HEX_VALUE ;
	WHERE _NAME_ = 'StdDevS' ;
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;EDIT: Slight mod to remove the notes in the log about character types.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT2: Tested on SAS 9.4 TS1M3 - you should make sure you're using the same versions as well, though I suspect that's not the issue - and it shouldn't be.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410974#M100443</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-06T20:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: PROC MEANS and PROC UNIVARIATE producing different results for summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410975#M100444</link>
      <description>&lt;P&gt;And if you need the data transposed look at the ODS SUMMARY table instead.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410975#M100444</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-06T20:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC MEANS and PROC UNIVARIATE producing different results for summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410979#M100446</link>
      <description>&lt;P&gt;I think you will need to take this up with SAS.&amp;nbsp; I ran a small test program against your example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc compare base=proc_mean compare=proc_univ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wasn't surprised to see that some variable labels are different.&amp;nbsp; But I was surprised to see that the standard deviations differ (to a tiny degree, on the order of e-18):&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|| StdDevS&amp;nbsp; &amp;nbsp;StdDevS&amp;nbsp; &amp;nbsp;Diff.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; % Diff&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;________ || _________ _________ _________ _________&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ||&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|| 0.005000 &amp;nbsp;0.005000&amp;nbsp; -2.6E-18&amp;nbsp; -5.2E-14&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;__________________________________________________________&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410979#M100446</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-06T20:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC MEANS and PROC UNIVARIATE producing different results for summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410985#M100450</link>
      <description>&lt;P&gt;Thanks Reeza!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I change to ROUND(), I get the same BASE_VALUE, however the HEX values are still different between the procedure. I am hesitant to change to ROUND() because this is just one mismatch example.&amp;nbsp; The various other statistics have matching results, only this one value for SD does not match between PROC UNIVARIATE and PROC MEANS after PUT().&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410985#M100450</guid>
      <dc:creator>arg1</dc:creator>
      <dc:date>2017-11-06T20:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: PROC MEANS and PROC UNIVARIATE producing different results for summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410986#M100451</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154641"&gt;@arg1&lt;/a&gt;&amp;nbsp;I agree. I think this is an artifact of the very small data and don't think the difference is significant. The values are the same, and I understand why you want confirmation though, and I think the next step would be SAS Tech Support.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you test it with a larger data set then it works fully as expected - the HEX and BASE values included. I think it's Excel that you can actually get it to return a negative variance - which isn't possible - but requires small N.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test ;
set sashelp.class;
value=weight;
	;
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:30:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-MEANS-and-PROC-UNIVARIATE-producing-different-results-for/m-p/410986#M100451</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-06T20:30:51Z</dc:date>
    </item>
  </channel>
</rss>

