LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2011)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 16 Jul 2011 11:22:42 +0200
Reply-To:     John F Hall <johnfhall@orange.fr>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         John F Hall <johnfhall@orange.fr>
Subject:      Re: Syntax for SAMPLE
Comments: To: David Marso <david.marso@gmail.com>
Comments: cc: Bruce Weaver <bweaver@lakeheadu.ca>,
          "Gregory, Cindy, PED" <Cindy.Gregory@state.nm.us>,
          Richard Ristow <wrristow@mindspring.com>
In-Reply-To:  <1310759107267-4591971.post@n5.nabble.com>
Content-Type: text/plain; charset="us-ascii"

David

Tried your syntax, but had to modify it a bit.

*Marso sample . * data set 'ql4gb1975.sav' . * variables: var544 (happy), var545 (lifesat), age . compute happy = var544. compute lifesat = var545 . compute caseid = serial . *** OK here we go **.

SPSS doesn't like SCRAMBLE and I can't find it anywhere in the Syntax Reference Guide, so I dumped it. The new file has four variables, but only one case. I was looking to create a data file with up to n cases corresponding to the number of samples drawn. I can then run SPSS to demonstrate the distributions of sample statistics with:

Freq MLIFESAT MEANAGE PctVHapp /for not /his .

Also the variables SAMPLE (all with value 101) CASEID ( 1 to 300) and GPCOUNT (1 to 300) are appended to the existing data set, which I don't particularly want, and the number of cases has dropped from 932 to 300, which I definitely don't want! Some of this complex syntax is new to me, but I did use Algol intensively in the 1960s (to manage and analyse survey data) so I can follow the logic. I haven't tried Bruce's syntax yet, or Dave Nicholls' earlier version, but if I can get something that works, it will be a valuable learning aid. Gives me something to do instead of gardening in the rain or catching up on 300 or so films, dramas and documentaries recorded from TV!

John

johnfhall@orange.fr www.surveyresearch.weebly.com

PS If you haven't already seen it, get Bruce to send you the slideshow.

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of David Marso Sent: 15 July 2011 21:45 To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: Syntax for SAMPLE

"Assume data set is BSA89.sav, N is 3000 and I want 100 samples of size 300: then to save mean lifesat, mean age and % very happy (code 3 on happy) as variables in a separate file with 100 cases (one for each sample)."

Here you go John, enjoy ;-) --- *** OK here we go **. **First of all oversample **. LOOP SAMPLE=1 TO 100. + DO IF UNIFORM(1) < .12 . + XSAVE OUTFILE "Samples.sav" / KEEP caseid lifesat age happy sample. + END IF. END LOOP. *ONE OF THE ONLY Places you NEED an EXECUTE *. EXECUTE. GET FILE "samples.sav". FREQ SAMPLE. * Using same ideas as what I posted to Cindy Gregory * COMPUTE SCRAMBLE=UNIFORM(1). SORT CASES BY SAMPLE SCRAMBLE. IF $CASENUM=1 OR LAG(SAMPLE) NE SAMPLE GPCount=1. IF MISSING( GPCount) GPCount=LAG(GPCount)+1.

*ONE OF THE ONLY Places you NEED an EXECUTE *. EXECUTE. SELECT IF GPCount LE 300. FREQ SAMPLE. AGGREGATE OUTFILE * / BREAK SAMPLE / MLIFESAT MEANAGE = MEAN(lifesat age) / PctVHapp=PIN(happy,3,3).

John F Hall wrote: > > David > > It was just a thought, and I was only trying to help! > > I once had a similar problem when trying to introduce students to > inferential statistics. I'd have say 24 students and a survey with 1800 > cases for a lab session. Each student was asked to sample n from N with a > different SET SEED starting point. This was in the days of 16 VDU's > connected to a remote Vax mainframe (12 working if you were lucky and > severe > time constraints if we didn't want to get locked in the building, or get > away before the Arsenal match finished up the road) not modern PCs and > distance learning. The idea was to get 3 samples each to yield 72 > statistics (mean lifesat, % happy or whatever) which we then plotted (on > the > chalk-board) hopefully to demonstrate a distribution with an approximately > normal distribution. Sometimes it worked, sometimes it didn't (usually > because sampling 30 from 3000 isn't as stable as 300 from 3000) but the > students learned a lot from the attempt and understood what we were trying > to do, especially that the sampling distribution of the mean was > approximately normal even if the variable itself was not (eg age) > > Now, how about some syntax to do what I need for a new tutorial for the > website? > > Assume data set is BSA89.sav, N is 3000 and I want 100 samples of size > 300: > then to save mean lifesat, mean age and % very happy (code 3 on happy) as > variables in a separate file with 100 cases (one for each sample). > > Have a nice weekend. > > John > > johnfhall@orange.fr > www.surveyresearch.weebly.com > > > > > > > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of > David Marso > Sent: 15 July 2011 19:33 > To: SPSSX-L@LISTSERV.UGA.EDU > Subject: Re: Syntax for SAMPLE > > It makes *NO* sense at all to use SAMPLE within a DO REPEAT. > Think about that for a moment ;-) > > When you do something like > DO REPEAT X= a b c d / Y = e f g h / Z= ae be cg dh. > COMPUTE Z=X/Y. > END REPEAT. > > what do you end up with? > 4 new variables on *EACH* case... > i.e. DO REPEAT handles TRANSFORMATIONS and applies to each case. > How would SAMPLE fit into a DO REPEAT? > > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/Syntax-for-SAMPLE-tp4591268p45 > 91568.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@LISTSERV.UGA.EDU (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 > LISTSERV@LISTSERV.UGA.EDU (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 >

-- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Syntax-for-SAMPLE-tp4591268p45 91971.html Sent from the SPSSX Discussion mailing list archive at Nabble.com.

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (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 LISTSERV@LISTSERV.UGA.EDU (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


Back to: Top of message | Previous page | Main SPSSX-L page