Calculation of variable length/sampling *exactly* 50%

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

Calculation of variable length/sampling *exactly* 50%

Robert L
I wanted to sample half of the individuals in a small dataset, but using the "approximately 50%" choice did not result in half the original group. Since the sampling will be repeated in several sets, it would be nice to have something like

*calculate the variable length, i e the number of individuals, in the set; assign this to the variable n

*make a sample of n/2 from the set

This should be easy, but I havent found out how to get the n. I could probably step through the variable in some loop, but that seems somewhat crude for what in my view should be a straightforward task. Any suggestions?

Robert

=====================
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
Robert Lundqvist
Reply | Threaded
Open this post in threaded view
|

Re: Calculation of variable length/sampling *exactly* 50%

Lemon, John S.

How about taking every alternate case ?

 

DATASET ACTIVATE DataSet1.

USE ALL.

COMPUTE filter_$=(MOD(($CASENUM/2),1)).

VARIABLE LABELS filter_$ 'MOD(($CASENUM/2),1) (FILTER)'.

VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'.

FORMATS filter_$ (f1.0).

FILTER BY filter_$.

EXECUTE.

 

 

Best Wishes

 

John S. Lemon

DIT ( Directorate of Information Technology ) - Student Liaison Officer

University of Aberdeen

Edward Wright Building: Room G86a

Tel:  +44 1224 273350

 

DIT news for Students

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Robert Lundqvist
Sent: 08 April 2011 09:22
To: [hidden email]
Subject: Calculation of variable length/sampling *exactly* 50%

 

I wanted to sample half of the individuals in a small dataset, but using the "approximately 50%" choice did not result in half the original group. Since the sampling will be repeated in several sets, it would be nice to have something like

 

*calculate the variable length, i e the number of individuals, in the set; assign this to the variable n

 

*make a sample of n/2 from the set

 

This should be easy, but I havent found out how to get the n. I could probably step through the variable in some loop, but that seems somewhat crude for what in my view should be a straightforward task. Any suggestions?

 

Robert

 

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

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



The University of Aberdeen is a charity registered in Scotland, No SC013683.
Reply | Threaded
Open this post in threaded view
|

Re: Calculation of variable length/sampling *exactly* 50%

Maclennan, Graeme S.
In reply to this post by Robert L
A little tweak of the code at http://www.spsstools.net/Syntax/RandomSampling/SplitFileInto10RandomGroups.txt gives.

datset close all.
GET
  FILE='C:\Program Files\SPSSInc\PASWStatistics18\Samples\English\Employee data.sav'.
COMPUTE draw=UNIFORM(1).
COMPUTE nobreak=1.
RANK  VARIABLES=draw  (A) BY nobreak  /NTILES (2).
* Check that it works.
FREQ VAR=ndraw.

This will give you two random subsets of your dataset size n/2 if n even, or size (n+1)/2 and (n-1)/2 if n is odd.
HTH.
Graeme.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Robert Lundqvist
Sent: 08 April 2011 09:22
To: [hidden email]
Subject: Calculation of variable length/sampling *exactly* 50%

I wanted to sample half of the individuals in a small dataset, but using the "approximately 50%" choice did not result in half the original group. Since the sampling will be repeated in several sets, it would be nice to have something like

*calculate the variable length, i e the number of individuals, in the set; assign this to the variable n

*make a sample of n/2 from the set

This should be easy, but I havent found out how to get the n. I could probably step through the variable in some loop, but that seems somewhat crude for what in my view should be a straightforward task. Any suggestions?

Robert

=====================
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


The University of Aberdeen is a charity registered in Scotland, No SC013683.

=====================
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