There are million ways to do this. but here is what worked for me. You will need your date of birth variable to have month, day and year.
COMPUTE age_year = (DATE.MDY(11,01,2010) - BirthDate) / (60*60*24*365.25) .
COMPUTE age=RND(age_year).
FORMATS age (F3.0).
*fre age.
NOTE: This will create an AGE variable, as of now, not the age of respondent at the time of survey. To do that you would need survey date.
I will try to collect all my SPSS/STATA and other stats notes here!!
Wednesday, 24 November 2010
Tuesday, 23 November 2010
String to Numeric in SPSS
STRING m1 (A10).
execute.
compute m1 = substr(query_co,1,1).
execute.
list m1.
Monday, 17 May 2010
Friday, 14 May 2010
Sampling definitions
Want to learn basics of sampling in surveys?
Here are some simple ones: http://www.gifted.uconn.edu/siegle/research/Samples/purposivesampling.htm
Here are some simple ones: http://www.gifted.uconn.edu/siegle/research/Samples/purposivesampling.htm
Thursday, 4 March 2010
Really useful site on SPSS
Check this out for a comprehensive and easy to use guide on SPSS command.
http://www.lrz-muenchen.de/~wlm/ein_spss.htm
http://www.lrz-muenchen.de/~wlm/ein_spss.htm
Friday, 6 November 2009
Creating a string variable to calculate BTH participation till 2006
*Create a string variable by the name years. The variable a width of 7 characters but i ended up using just one. Then Use IF command to assign "1" to the variable in all cases where the year was less than 2006.*****
string years (A7).
if year1="2001-02" | year1="2002-03" | year1="2003-04" | year1="2004-05" | year1="2005-06" years="1".
if year2="2001-02" | year1="2002-03" | year1="2003-04" | year1="2004-05" | year1="2005-06" years="1".
if year3="2001-02" | year1="2002-03" | year1="2003-04" | year1="2004-05" | year1="2005-06" years="1".
if year4="2001-02" | year1="2002-03" | year1="2003-04" | year1="2004-05" | year1="2005-06" years="1".
if year5="2001-02" | year1="2002-03" | year1="2003-04" | year1="2004-05" | year1="2005-06" years="1".
fre years.
list Year1 Year2 Year3 Year4 Year5 TotalYears years.
**Frequency of only those cases who meet the above criteria, ie less than 2006********.
temp.
select if years="1".
fre TotalYears/sta=all.
string years (A7).
if year1="2001-02" | year1="2002-03" | year1="2003-04" | year1="2004-05" | year1="2005-06" years="1".
if year2="2001-02" | year1="2002-03" | year1="2003-04" | year1="2004-05" | year1="2005-06" years="1".
if year3="2001-02" | year1="2002-03" | year1="2003-04" | year1="2004-05" | year1="2005-06" years="1".
if year4="2001-02" | year1="2002-03" | year1="2003-04" | year1="2004-05" | year1="2005-06" years="1".
if year5="2001-02" | year1="2002-03" | year1="2003-04" | year1="2004-05" | year1="2005-06" years="1".
fre years.
list Year1 Year2 Year3 Year4 Year5 TotalYears years.
**Frequency of only those cases who meet the above criteria, ie less than 2006********.
temp.
select if years="1".
fre TotalYears/sta=all.
Wednesday, 16 September 2009
Really basic stats: what can we do with these variables?
Here is a quick guide for statistics that are ok to compute with kind of variable:
Source: http://www.graphpad.com/faq/viewfaq.cfm?faq=1089
| OK to compute.... | Nominal | Ordinal | Interval | Ratio |
| frequency distribution. | Yes | Yes | Yes | Yes |
| median and percentiles. | No | Yes | Yes | Yes |
| add or subtract. | No | No | Yes | Yes |
| mean, standard deviation, standard error of the mean. | No | No | Yes | Yes |
| ratio, or coefficient of variation. | No | No | No | Yes |
Source: http://www.graphpad.com/faq/viewfaq.cfm?faq=1089
Subscribe to:
Posts (Atom)