Write cases using a weight to multiply N

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Write cases using a weight to multiply N

John F Hall

I’m trying to create a raw data set relating to a published table.  There are two rows (sex) and four columns (age group) in the table.  The original data had 15,900 cases, but I’ve used n/100 as a weight variable.

 

I have three variables, sex agegroup and weight which I’ve typed into the Data Editor as eight rows of data.

 

1             1             8.81

1             2             26.28

1             3             22.15

1             4             14.45

2             1             9.69

2             2             31.82

2             3             25.09

2             4             18.36

 

weight by weight.

crosstabs sex by agegroup.

 

Produces a table with reduced N

 

 

Sex * Agegroup Crosstabulation

Count

 

Agegroup

Total

1

2

3

4

Sex

1

9

26

22

14

71

2

10

32

25

18

85

Total

19

58

47

32

156

print format sex agegroup (f2.0).

WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'  /sex agegroup.

exec.

 

.produces a txt file, which only has 8 cases. 

 

1 1

1 2

1 3

1 4

2 1

2 2

2 3

2 4

 

How can I get SPSS to generate a file with 156 cases using the weight variable?

 

I have quite a lot of table to process like this, all from different sources.

 

Thanks in advance

 

John F Hall (Mr)

[retired academic survey researcher]

 

Email:     [hidden email]

Website: www.surveyresearch.weebly.com

 

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Write cases using a weight to multiply N

David Marso
Administrator
Perhaps:
LOOP #=1 TO RND(weight).
XSAVE OUTFILE 'C:\temp\test.sav' / keep sex agegroup.
END LOOP.

EXECUTE.
GET FILE  'C:\temp\test.sav' .
CROSSTABS TABLE sex BY agegroup.

----
John F Hall wrote
I'm trying to create a raw data set relating to a published table.  There
are two rows (sex) and four columns (age group) in the table.  The original
data had 15,900 cases, but I've used n/100 as a weight variable.

I have three variables, sex agegroup and weight which I've typed into the
Data Editor as eight rows of data.

1             1             8.81
1             2             26.28
1             3             22.15
1             4             14.45
2             1             9.69
2             2             31.82
2             3             25.09
2             4             18.36

weight by weight.
crosstabs sex by agegroup.

Produces a table with reduced N



Sex * Agegroup Crosstabulation

Count


Agegroup
Total

1
2
3
4

Sex
1
9
26
22
14
71

2
10
32
25
18
85

Total
19
58
47
32
156
print format sex agegroup (f2.0).
WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'  /sex agegroup.
exec.

.produces a txt file, which only has 8 cases.

1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4

How can I get SPSS to generate a file with 156 cases using the weight
variable?

I have quite a lot of table to process like this, all from different
sources.

Thanks in advance

John F Hall (Mr)
[retired academic survey researcher]

Email:      <mailto:[hidden email]> [hidden email]
Website:  <http://surveyresearch.weebly.com/> www.surveyresearch.weebly.com
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Write cases using a weight to multiply N

Jon K Peck
In reply to this post by John F Hall
Crosstabs offers five ways to treat fractional weights.
COUNT subcommand
The COUNT subcommand controls how case weights are handled.
ASIS The case weights are used as is. However, when Exact Statistics are requested,
the accumulated weights in the cells are either truncated or rounded before
computing the Exact test statistics.
CASE The case weights are either rounded or truncated before use.
CELL The case weights are used as is but the accumulated weights in the cells are
either truncated or rounded before computing any statistics.
ROUND Performs Rounding operation.
TRUNCATE Performs Truncation operation.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        John F Hall <[hidden email]>
To:        [hidden email],
Date:        02/20/2013 11:40 AM
Subject:        [SPSSX-L] Write cases using a weight to multiply N
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I’m trying to create a raw data set relating to a published table.  There are two rows (sex) and four columns (age group) in the table.  The original data had 15,900 cases, but I’ve used n/100 as a weight variable.

 

I have three variables, sex agegroup and weight which I’ve typed into the Data Editor as eight rows of data.

 

1             1             8.81

1             2             26.28

1             3             22.15

1             4             14.45

2             1             9.69

2             2             31.82

2             3             25.09

2             4             18.36

 

weight by weight.

crosstabs sex by agegroup.

 

Produces a table with reduced N

 

 

Sex * Agegroup Crosstabulation
Count
 
Agegroup
Total
1
2
3
4
Sex 1
9
26
22
14
71
2
10
32
25
18
85
Total
19
58
47
32
156

print format sex agegroup (f2.0).

WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'  /sex agegroup.

exec.

 

.produces a txt file, which only has 8 cases.  

 
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4

 

How can I get SPSS to generate a file with 156 cases using the weight variable?

 

I have quite a lot of table to process like this, all from different sources.

 

Thanks in advance

 

John F Hall (Mr)

[retired academic survey researcher]

 

Email:     johnfhall@...

Website: www.surveyresearch.weebly.com

 

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Write cases using a weight to multiply N

John F Hall
In reply to this post by David Marso
David

Thanks for that.  I had to modify the syntax a bit to:

LOOP #=1 TO RND(weight).
XSAVE OUTFILE 'C:\Users\John\Desktop\begstat.sav'
 / keep sex agegroup.
END LOOP.
EXECUTE.
GET FILE  'C:\Users\John\Desktop\begstat1.sav'  .

This gives me a file with 156 cases which is what I wanted and enables me to
write a raw data file in *.txt format with:

WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'
 /sex agegroup.
exec.

I could also export an Excel file.  Either type can then be read back to
SPSS in an exercise.

The initial table (N = 15,900) is from Ian Diamond and Julie Jefferies,
"Beginning Statistics" (Sage 2001, reprinted 2012) but they're planning a
new edition (with Liam Foster) and welcome comments and suggestions.

If I can follow the logic for more complex tables I can generate raw data
files in which there could be three variables, with a mix of numeric and
strings, to demonstrate to students how data need to be:

1: sorted, counted and tabulated.
2: perceived as dependent and independent variables, standardised as %% and
tabulated again
3: converted to numeric in SPSS, with a test variable added and tabulated
again with appropriate choice of percentages.

Sounds very elementary, but demonstrates the underlying logic behind all
survey analysis as well as the practical steps needed.

It would be even better if I could randomise the order of the cases in the
file as well.  I could always generate a huge file using the original
4-figure weights and then use SAMPLE 159 from 15,900, but is there an easy
way to randomise the order of cases in the smaller file?

Again, many thanks.

John





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Marso
Sent: 20 February 2013 20:14
To: [hidden email]
Subject: Re: Write cases using a weight to multiply N

Perhaps:
LOOP #=1 TO RND(weight).
XSAVE OUTFILE 'C:\temp\test.sav' / keep sex agegroup.
END LOOP.

EXECUTE.
GET FILE  'C:\temp\test.sav' .
CROSSTABS TABLE sex BY agegroup.

----

John F Hall wrote

> I'm trying to create a raw data set relating to a published table.
> There are two rows (sex) and four columns (age group) in the table.
> The original data had 15,900 cases, but I've used n/100 as a weight
> variable.
>
> I have three variables, sex agegroup and weight which I've typed into
> the Data Editor as eight rows of data.
>
> 1             1             8.81
> 1             2             26.28
> 1             3             22.15
> 1             4             14.45
> 2             1             9.69
> 2             2             31.82
> 2             3             25.09
> 2             4             18.36
>
> weight by weight.
> crosstabs sex by agegroup.
>
> Produces a table with reduced N
>
>
>
> Sex * Agegroup Crosstabulation
>
> Count
>
>
> Agegroup
> Total
>
> 1
> 2
> 3
> 4
>
> Sex
> 1
> 9
> 26
> 22
> 14
> 71
>
> 2
> 10
> 32
> 25
> 18
> 85
>
> Total
> 19
> 58
> 47
> 32
> 156
> print format sex agegroup (f2.0).
> WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'  /sex agegroup.
> exec.
>
> .produces a txt file, which only has 8 cases.
>
> 1 1
> 1 2
> 1 3
> 1 4
> 2 1
> 2 2
> 2 3
> 2 4
>
> How can I get SPSS to generate a file with 156 cases using the weight
> variable?
>
> I have quite a lot of table to process like this, all from different
> sources.
>
> Thanks in advance
>
> John F Hall (Mr)
> [retired academic survey researcher]
>
> Email:      &lt;mailto:

> johnfhall@

> &gt;

> johnfhall@

> Website:  &lt;http://surveyresearch.weebly.com/&gt;
> www.surveyresearch.weebly.com





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email
me.
--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Write-cases-using-a-weight-to-
multiply-N-tp5718153p5718155.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Write cases using a weight to multiply N

Kylie Lange-3
Hi John,

>> but is there an easy way to randomise the order of cases in the smaller file?

I'd simply compute a new variable of random numbers and then sort the file by that variable.

Cheers,
Kylie.


________________________________________
From: SPSSX(r) Discussion [[hidden email]] on behalf of John F Hall [[hidden email]]
Sent: Thursday, 21 February 2013 12:04 PM
To: [hidden email]
Subject: Re: Write cases using a weight to multiply N

David

Thanks for that.  I had to modify the syntax a bit to:

LOOP #=1 TO RND(weight).
XSAVE OUTFILE 'C:\Users\John\Desktop\begstat.sav'
 / keep sex agegroup.
END LOOP.
EXECUTE.
GET FILE  'C:\Users\John\Desktop\begstat1.sav'  .

This gives me a file with 156 cases which is what I wanted and enables me to
write a raw data file in *.txt format with:

WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'
 /sex agegroup.
exec.

I could also export an Excel file.  Either type can then be read back to
SPSS in an exercise.

The initial table (N = 15,900) is from Ian Diamond and Julie Jefferies,
"Beginning Statistics" (Sage 2001, reprinted 2012) but they're planning a
new edition (with Liam Foster) and welcome comments and suggestions.

If I can follow the logic for more complex tables I can generate raw data
files in which there could be three variables, with a mix of numeric and
strings, to demonstrate to students how data need to be:

1: sorted, counted and tabulated.
2: perceived as dependent and independent variables, standardised as %% and
tabulated again
3: converted to numeric in SPSS, with a test variable added and tabulated
again with appropriate choice of percentages.

Sounds very elementary, but demonstrates the underlying logic behind all
survey analysis as well as the practical steps needed.

It would be even better if I could randomise the order of the cases in the
file as well.  I could always generate a huge file using the original
4-figure weights and then use SAMPLE 159 from 15,900, but is there an easy
way to randomise the order of cases in the smaller file?

Again, many thanks.

John





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Marso
Sent: 20 February 2013 20:14
To: [hidden email]
Subject: Re: Write cases using a weight to multiply N

Perhaps:
LOOP #=1 TO RND(weight).
XSAVE OUTFILE 'C:\temp\test.sav' / keep sex agegroup.
END LOOP.

EXECUTE.
GET FILE  'C:\temp\test.sav' .
CROSSTABS TABLE sex BY agegroup.

----

John F Hall wrote

> I'm trying to create a raw data set relating to a published table.
> There are two rows (sex) and four columns (age group) in the table.
> The original data had 15,900 cases, but I've used n/100 as a weight
> variable.
>
> I have three variables, sex agegroup and weight which I've typed into
> the Data Editor as eight rows of data.
>
> 1             1             8.81
> 1             2             26.28
> 1             3             22.15
> 1             4             14.45
> 2             1             9.69
> 2             2             31.82
> 2             3             25.09
> 2             4             18.36
>
> weight by weight.
> crosstabs sex by agegroup.
>
> Produces a table with reduced N
>
>
>
> Sex * Agegroup Crosstabulation
>
> Count
>
>
> Agegroup
> Total
>
> 1
> 2
> 3
> 4
>
> Sex
> 1
> 9
> 26
> 22
> 14
> 71
>
> 2
> 10
> 32
> 25
> 18
> 85
>
> Total
> 19
> 58
> 47
> 32
> 156
> print format sex agegroup (f2.0).
> WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'  /sex agegroup.
> exec.
>
> .produces a txt file, which only has 8 cases.
>
> 1 1
> 1 2
> 1 3
> 1 4
> 2 1
> 2 2
> 2 3
> 2 4
>
> How can I get SPSS to generate a file with 156 cases using the weight
> variable?
>
> I have quite a lot of table to process like this, all from different
> sources.
>
> Thanks in advance
>
> John F Hall (Mr)
> [retired academic survey researcher]
>
> Email:      &lt;mailto:

> johnfhall@

> &gt;

> johnfhall@

> Website:  &lt;http://surveyresearch.weebly.com/&gt;
> www.surveyresearch.weebly.com





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email
me.
--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Write-cases-using-a-weight-to-
multiply-N-tp5718153p5718155.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Write cases using a weight to multiply N

Bruce Weaver
Administrator
In reply to this post by John F Hall
John, to randomise the order, compute a random number, then sort on it, and save the file.  If you don't want the variable holding the random number in the file, DROP it while saving the file.  I don't have SPSS on this machine, so the following is untested.

COMPUTE junk = uniform(100).
EXECUTE.
SORT CASES by junk.
SAVE OUTFILE = "C:\MyFolder\MyFile.sav" / DROP = junk.



John F Hall wrote
David

Thanks for that.  I had to modify the syntax a bit to:

LOOP #=1 TO RND(weight).
XSAVE OUTFILE 'C:\Users\John\Desktop\begstat.sav'
 / keep sex agegroup.
END LOOP.
EXECUTE.
GET FILE  'C:\Users\John\Desktop\begstat1.sav'  .

This gives me a file with 156 cases which is what I wanted and enables me to
write a raw data file in *.txt format with:

WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'
 /sex agegroup.
exec.

I could also export an Excel file.  Either type can then be read back to
SPSS in an exercise.

The initial table (N = 15,900) is from Ian Diamond and Julie Jefferies,
"Beginning Statistics" (Sage 2001, reprinted 2012) but they're planning a
new edition (with Liam Foster) and welcome comments and suggestions.

If I can follow the logic for more complex tables I can generate raw data
files in which there could be three variables, with a mix of numeric and
strings, to demonstrate to students how data need to be:

1: sorted, counted and tabulated.
2: perceived as dependent and independent variables, standardised as %% and
tabulated again
3: converted to numeric in SPSS, with a test variable added and tabulated
again with appropriate choice of percentages.

Sounds very elementary, but demonstrates the underlying logic behind all
survey analysis as well as the practical steps needed.

It would be even better if I could randomise the order of the cases in the
file as well.  I could always generate a huge file using the original
4-figure weights and then use SAMPLE 159 from 15,900, but is there an easy
way to randomise the order of cases in the smaller file?

Again, many thanks.

John





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Marso
Sent: 20 February 2013 20:14
To: [hidden email]
Subject: Re: Write cases using a weight to multiply N

Perhaps:
LOOP #=1 TO RND(weight).
XSAVE OUTFILE 'C:\temp\test.sav' / keep sex agegroup.
END LOOP.

EXECUTE.
GET FILE  'C:\temp\test.sav' .
CROSSTABS TABLE sex BY agegroup.

----

John F Hall wrote
> I'm trying to create a raw data set relating to a published table.
> There are two rows (sex) and four columns (age group) in the table.
> The original data had 15,900 cases, but I've used n/100 as a weight
> variable.
>
> I have three variables, sex agegroup and weight which I've typed into
> the Data Editor as eight rows of data.
>
> 1             1             8.81
> 1             2             26.28
> 1             3             22.15
> 1             4             14.45
> 2             1             9.69
> 2             2             31.82
> 2             3             25.09
> 2             4             18.36
>
> weight by weight.
> crosstabs sex by agegroup.
>
> Produces a table with reduced N
>
>
>
> Sex * Agegroup Crosstabulation
>
> Count
>
>
> Agegroup
> Total
>
> 1
> 2
> 3
> 4
>
> Sex
> 1
> 9
> 26
> 22
> 14
> 71
>
> 2
> 10
> 32
> 25
> 18
> 85
>
> Total
> 19
> 58
> 47
> 32
> 156
> print format sex agegroup (f2.0).
> WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'  /sex agegroup.
> exec.
>
> .produces a txt file, which only has 8 cases.
>
> 1 1
> 1 2
> 1 3
> 1 4
> 2 1
> 2 2
> 2 3
> 2 4
>
> How can I get SPSS to generate a file with 156 cases using the weight
> variable?
>
> I have quite a lot of table to process like this, all from different
> sources.
>
> Thanks in advance
>
> John F Hall (Mr)
> [retired academic survey researcher]
>
> Email:      <mailto:

> johnfhall@

> >

> johnfhall@

> Website:  <http://surveyresearch.weebly.com/>
> www.surveyresearch.weebly.com





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email
me.
--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Write-cases-using-a-weight-to-
multiply-N-tp5718153p5718155.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
Reply | Threaded
Open this post in threaded view
|

Re: Write cases using a weight to multiply N

John F Hall

Kylie, Bruce

 

Thanks for rapid response to this inSPSSomniac (04h08 here).  Thanks Bruce for the syntax.  Works a treat.  I've actually produced a file with 15665 cases containing numeric variables Sex and Agegroup plus artificially generated strings Gender and Age2.  Now they are nicely jumbled up, as well as reproducing the original table counts.

 

Sex of R * Age of R (grouped) Crosstabulation

Count

 

Age of R (grouped)

Total

16-24

25-44

45-64

65 and over

Sex of R

Male

881

2628

2215

1445

7169

Female

969

3182

2509

1836

8496

Total

1850

5810

4724

3281

15665

 

 

I can now sample n from N and LIST gender age2 /CASES <n> for the string variables,

 

Female 45-64

Female 25-44

Male   25-44

Female 65+

Female 45-64

Male   25-44

Female 16-24

Male   65+

Female 25-44

Male   25-44

Male   25-44

Male   25-44

Male   16-24

Female 25-44

Male   16-24

Female 25-44

Female 65+

Female 25-44

Male   65+

 

. . etc., then progressively sort these into some kind of order by sex and agegroup separately, then jointly, before summarising them in frequency and contingency tables (counts only), finally standardising them and using %%% instead.  The sequence of outputs can then go into a tutorial.

 

This will take a bit of fiddling about with various SORT BY commands, but I'll create an ID from $casenum in the jumbled file so I can always sort back into the original case order.

 

Now that I've got my head round the syntax needed to create raw data from published tables, I can apply it to many others in this and other books.

 

Incidentally, even after 41 years of using SPSS, I think it's the first time I've ever created a string from a numeric.  Took me a couple of tries before I checked the manual and realised I needed to declare the strings and their formats before using RECODE ...INTO.  Never too old to learn eh?

 

John

 

John F Hall (Mr)

[retired academic survey researcher]

 

Email:     [hidden email]

Website: www.surveyresearch.weebly.com

 

 

 

 

 

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: 21 February 2013 02:58
To: [hidden email]
Subject: Re: Write cases using a weight to multiply N

 

John, to randomise the order, compute a random number, then sort on it, and save the file.  If you don't want the variable holding the random number in the file, DROP it while saving the file.  I don't have SPSS on this machine, so the following is untested.

 

COMPUTE junk = uniform(100).

EXECUTE.

SORT CASES by junk.

SAVE OUTFILE = "C:\MyFolder\MyFile.sav" / DROP = junk.

 

 

 

 

John F Hall wrote

> David

> 

> Thanks for that.  I had to modify the syntax a bit to:

> 

> LOOP #=1 TO RND(weight).

> XSAVE OUTFILE 'C:\Users\John\Desktop\begstat.sav'

>  / keep sex agegroup.

> END LOOP.

> EXECUTE.

> GET FILE  'C:\Users\John\Desktop\begstat1.sav'  .

> 

> This gives me a file with 156 cases which is what I wanted and enables

> me to write a raw data file in *.txt format with:

> 

> WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'

>  /sex agegroup.

> exec.

> 

> I could also export an Excel file.  Either type can then be read back

> to SPSS in an exercise.

> 

> The initial table (N = 15,900) is from Ian Diamond and Julie

> Jefferies, "Beginning Statistics" (Sage 2001, reprinted 2012) but

> they're planning a new edition (with Liam Foster) and welcome comments and suggestions.

> 

> If I can follow the logic for more complex tables I can generate raw

> data files in which there could be three variables, with a mix of

> numeric and strings, to demonstrate to students how data need to be:

> 

> 1: sorted, counted and tabulated.

> 2: perceived as dependent and independent variables, standardised as

> %% and tabulated again

> 3: converted to numeric in SPSS, with a test variable added and

> tabulated again with appropriate choice of percentages.

> 

> Sounds very elementary, but demonstrates the underlying logic behind

> all survey analysis as well as the practical steps needed.

> 

> It would be even better if I could randomise the order of the cases in

> the file as well.  I could always generate a huge file using the

> original 4-figure weights and then use SAMPLE 159 from 15,900, but is

> there an easy way to randomise the order of cases in the smaller file?

> 

> Again, many thanks.

> 

> John

> 

> 

> 

> 

> 

> -----Original Message-----

> From: SPSSX(r) Discussion [mailto:

 

> [hidden email]

 

> ] On Behalf Of

> David Marso

> Sent: 20 February 2013 20:14

> To:

 

> [hidden email]

 

> Subject: Re: Write cases using a weight to multiply N

> 

> Perhaps:

> LOOP #=1 TO RND(weight).

> XSAVE OUTFILE 'C:\temp\test.sav' / keep sex agegroup.

> END LOOP.

> 

> EXECUTE.

> GET FILE  'C:\temp\test.sav' .

> CROSSTABS TABLE sex BY agegroup.

> 

> ----

> 

> John F Hall wrote

>> I'm trying to create a raw data set relating to a published table.

>> There are two rows (sex) and four columns (age group) in the table.

>> The original data had 15,900 cases, but I've used n/100 as a weight

>> variable.

>> 

>> I have three variables, sex agegroup and weight which I've typed into

>> the Data Editor as eight rows of data.

>> 

>> 1             1             8.81

>> 1             2             26.28

>> 1             3             22.15

>> 1             4             14.45

>> 2             1             9.69

>> 2             2             31.82

>> 2             3             25.09

>> 2             4             18.36

>> 

>> weight by weight.

>> crosstabs sex by agegroup.

>> 

>> Produces a table with reduced N

>> 

>> 

>> 

>> Sex * Agegroup Crosstabulation

>> 

>> Count

>> 

>> 

>> Agegroup

>> Total

>> 

>> 1

>> 2

>> 3

>> 4

>> 

>> Sex

>> 1

>> 9

>> 26

>> 22

>> 14

>> 71

>> 

>> 2

>> 10

>> 32

>> 25

>> 18

>> 85

>> 

>> Total

>> 19

>> 58

>> 47

>> 32

>> 156

>> print format sex agegroup (f2.0).

>> WRITE OUTFILE='C:\Users\John\Desktop\begstat.txt'  /sex agegroup.

>> exec.

>> 

>> .produces a txt file, which only has 8 cases.

>> 

>> 1 1

>> 1 2

>> 1 3

>> 1 4

>> 2 1

>> 2 2

>> 2 3

>> 2 4

>> 

>> How can I get SPSS to generate a file with 156 cases using the weight

>> variable?

>> 

>> I have quite a lot of table to process like this, all from different

>> sources.

>> 

>> Thanks in advance

>> 

>> John F Hall (Mr)

>> [retired academic survey researcher]

>> 

>> Email:      &lt;mailto:

> 

>> johnfhall@

> 

>> &gt;

> 

>> johnfhall@

> 

>> Website:  &lt;http://surveyresearch.weebly.com/&gt;

>> www.surveyresearch.weebly.com

> 

> 

> 

> 

> 

> -----

> Please reply to the list and not to my personal email.

> Those desiring my consulting or training services please feel free to

> email me.

> --

> View this message in context:

> http://spssx-discussion.1045642.n5.nabble.com/Write-cases-using-a-weig

> ht-to-

> multiply-N-tp5718153p5718155.html

> Sent from the SPSSX Discussion mailing list archive at Nabble.com.

> 

> =====================

> To manage your subscription to SPSSX-L, send a message to

 

> [hidden email]

 

>  (not to SPSSX-L), with no body text except the command. To leave the

> list, send the command SIGNOFF SPSSX-L For a list of commands to

> manage subscriptions, send the command INFO REFCARD

> 

> =====================

> To manage your subscription to SPSSX-L, send a message to

 

> [hidden email]

 

>  (not to SPSSX-L), with no body text except the command. To leave the

> list, send the command SIGNOFF SPSSX-L For a list of commands to

> manage subscriptions, send the command INFO REFCARD

 

 

 

 

 

-----

--

Bruce Weaver

[hidden email]

http://sites.google.com/a/lakeheadu.ca/bweaver/

 

"When all else fails, RTFM."

 

NOTE: My Hotmail account is not monitored regularly.

To send me an e-mail, please use the address shown above.

 

--

View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Write-cases-using-a-weight-to-multiply-N-tp5718153p5718167.html

Sent from the SPSSX Discussion mailing list archive at Nabble.com.

 

=====================

To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

Reply | Threaded
Open this post in threaded view
|

Re: Write cases using a weight to multiply N

Robert Jones
If you ever wanted to recover the original sequence, then using the miscellaneous $casenum function to create a casenum variable can be used before sorting.