Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: Scoring the SF-12v2


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Scoring the SF-12v2
Date   Thu, 9 Feb 2006 16:08:36 -0000

I just love the way that the means and 
SDs of scores based on 1-5 ratings can 
be quoted to up to 7 significant figures. 

More seriously, a small point of style
that applies to other problems too. A line like 

replace `l' = . if `l' != 1 & `l' != 2 &`l' != 3 &`l' != 4
&`l' != 5

can also be written 

replace `l' = . if !inlist(`l', 1, 2, 3, 4, 5) 

It's quite easy to miss new Stata functions, which 
tend to be added without fanfare and documented without 
detailed examples. -inlist()- and its sibling 
-inrange()- have been around for a few versions now. 

Nick 
[email protected] 

Scott Merryman
 
> Googling - SF-12v2 How to score version 2 - points to a SAS 
> program by Ron Hays at:
> 
> http://gim.med.ucla.edu/FacultyPages/Hays/util.htm
> 
> It is straight forward to convert to a Stata program.  I have 
> no idea if the
> program is correct or if the various factors that are hard coded (US
> population means and stand deviations and the varimax-rotated 
> factor scoring
> coefficients) are correct.
> 
> Below it the do-file to replicate Dr. Hays' SAS output and 
> the Stata program
> sf12v2
> 
> Hope this helps,
> Scott
> 
> 
> ----------do-file----------
> clear
> input I1-I12
> 1 1 1 1 1 1 1 1 1 1 1 1 
> 1 1 3 3 3 3 3 3 3 3 3 3 
> 1 1 . 3 3 3 3 3 3 3 3 3 
> 5 5 1 1 1 . . . . . . . 
> end
> 
> // Rename variables
> local i = 1
> foreach l in I1   I2A  I2B  I3A  I3B  I4A  I4B  I5   I6A  I6B 
>  I6C  I7 {
> 	capture: rename I`i' `l'
> 	local ++i
> 	}
> l
> sf12v2
> 
> ----------sf12v2-------------
> 
> program sf12v2
> 	version 9.1
> 	qui {
> 	
> 	// Code out-of-range values to missing
> 	foreach l in I1 I3A I3B I4A I4B I5 I6A I6B I6C I7 {
> 		replace `l' = . if `l' != 1 & `l' != 2 &`l' != 
> 3 &`l' != 4
> &`l' != 5
> 	}
> 		
> 	foreach l in I2A I2B {
> 		replace `l' =.  if `l' != 1 & `l' != 2 &`l' != 3
> 	}

etc. 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index