12.07.2015 Views

SPSS Programming and Data Management, 4th Edition: A Guide for ...

SPSS Programming and Data Management, 4th Edition: A Guide for ...

SPSS Programming and Data Management, 4th Edition: A Guide for ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

17Best Practices <strong>and</strong> Efficiency Tips• Use /* <strong>and</strong> */ to set off a comment within a comm<strong>and</strong>.• The closing */ is optional when the comment is at the end of the line. The comm<strong>and</strong>can continue onto the next line just as if the inserted comment were a blank.• To ensure that comments that refer to macros by name don’t accidently invokethose macros, use the /* [comment text] */ <strong>for</strong>mat.Using SET SEED to Reproduce R<strong>and</strong>om Samples or ValuesWhen doing research involving r<strong>and</strong>om numbers—<strong>for</strong> example, when r<strong>and</strong>omlyassigning cases to experimental treatment groups—you should explicitly set ther<strong>and</strong>om number seed value if you want to be able to reproduce the same results.The r<strong>and</strong>om number generator is used by the SAMPLE comm<strong>and</strong> to generate r<strong>and</strong>omsamples <strong>and</strong> is used by many distribution functions (<strong>for</strong> example, NORMAL, UNIFORM)to generate distributions of r<strong>and</strong>om numbers. The generator begins with a seed,alargeinteger. Starting with the same seed, the system will repeatedly produce the samesequence of numbers <strong>and</strong> will select the same sample from a given data file. At thestart of each session, the seed is set to a value that may vary or may be fixed, dependingon your current settings. The seed value changes each time a series of trans<strong>for</strong>mationscontains one or more comm<strong>and</strong>s that use the r<strong>and</strong>om number generator.ExampleTo repeat the same r<strong>and</strong>om distribution within a session or in subsequent sessions, useSET SEED be<strong>for</strong>e each series of trans<strong>for</strong>mations that use the r<strong>and</strong>om number generatorto explicitly set the seed value to a constant value.*set_seed.sps.GET FILE = 'c:\examples\data\onevar.sav'.SET SEED = 123456789.SAMPLE .1.LIST.GET FILE = 'c:\examples\data\onevar.sav'.SET SEED = 123456789.SAMPLE .1.LIST.• Be<strong>for</strong>e the first sample is taken the first time, the seed value is explicitly set withSET SEED.• The LIST comm<strong>and</strong> causes the data to be read <strong>and</strong> the r<strong>and</strong>om number generatorto be invoked once <strong>for</strong> each original case. The result is an updated seed value.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!