/* Cochran Sample Size for Normality.jsl 10Nov2010 Copyright (c) 2010 by SAS Institute Inc., Cary, NC 27513, USA. All rights reserved. Note: please read the disclaimer at the end of this script. Purpose This script computes the sample size required to achieve a normal distribution of the sum of random variables based on the Cochran and Sugden methods described in: Sugden, R. A., et al. (2002) "Cochran's Rule for Simple Random Sampling, J of the Royal Statistical Society, Series B, Statistical Methodology. 62(4):787-793. Author Mark Bailey (SAS Institute) Contact mark.bailey@sas.com Usage Simply run this script by any one of these methods: Edit > Run Script Control-R Click "Run Script" button in tool bar Future Improvement Ideas None at this time. */ Names Default To Here( 1 ); dlg = Column Dialog( yCol = Col List( "Y", Min Col(1), Max Col(1), Data Type( Numeric ) ) ); If( dlg["Button"] == -1, Throw( "User cancelled" ) ); Remove From( dlg ); Eval List( dlg ); d = Distribution( Y( yCol[1] ) ); d << More Moments; dr = d << Report; y = yCol[1] << Get As Matrix; meanY = Mean( y ); n = N Row(y); g1 = (Summation( i=1, n, (y[i]-meanY)^3 )/n) / ((Summation( i=1, N Row(y), (y[i]-meanY)^2 )/n)^1.5); correctG1 = Sqrt( n*(n-1) ) * g1 / (n-2); CochranN = Round( 25*correctG1^2, 0 ); SugdenN = CochranN + 28; dr << Append( Outline Box( "Skewness", Table Box( String Col Box( "Statistic", { "g1", "G1", "Cochran n", "Sugden n" } ), Number Col Box( "Estimate", Matrix( { g1, correctG1, CochranN, SugdenN }) ) ) ) ); /* Revision History (date, change, person) 10Nov2010, created, Mark Bailey */ /* Disclaimer by SAS Institute Inc. License Agreement for Corrective Code or Additional Functionality SAS INSTITUTE INC. IS PROVIDING YOU WITH THE COMPUTER SOFTWARE CODE INCLUDED WITH THIS AGREEMENT ("CODE") ON AN "AS IS" BASIS, AND AUTHORIZES YOU TO USE THE CODE SUBJECT TO THE TERMS HEREOF. BY USING THE CODE, YOU AGREE TO THESE TERMS. YOUR USE OF THE CODE IS AT YOUR OWN RISK. SAS INSTITUTE INC. MAKES NO REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT AND TITLE, WITH RESPECT TO THE CODE. The Code is intended to be used solely as part of a product ("Software") you currently have licensed from SAS or one of its subsidiaries or authorized agents ("SAS"). The Code is designed to either correct an error in the Software or to add functionality to the Software, but has not necessarily been tested. Accordingly, SAS makes no representation or warranty that the Code will operate error-free. SAS is under no obligation to maintain or support the Code. Neither SAS nor its licensors shall be liable to you or any third party for any general, special, direct, indirect, consequential, incidental or other damages whatsoever arising out of or related to your use or inability to use the Code, even if SAS has been advised of the possibility of such damages. Except as otherwise provided above, the Code is governed by the same agreement that governs the Software. If you do not have an existing agreement with SAS governing the Software, you may not use the Code. (SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies.) */