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 (June 2000)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sat, 17 Jun 2000 17:53:16 -0400
Reply-To:   Raynald Levesque <rlevesque@VIDEOTRON.CA>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Raynald Levesque <rlevesque@VIDEOTRON.CA>
Subject:   Re: feasibility question
Content-type:   text/plain; charset=iso-8859-1

Hi

I believe the following syntax does the job for one variable.

SET MPRINT=ON. * Define a data file for illustration purposes. NEW file. input program. set seed=987654321. loop casenum=1 to 100. compute draw=uniform(100). compute class1=rnd(uniform(1)). end case. end loop. end file. end input program. execute.

*It is important to define this dummy variable in the main data file. COMPUTE dummy=1. SAVE OUTFILE='temp.sav'.

* Say you need to determine deciles (divide data in 10 pieces) based on cases where class1=1. * and that you must then recode ALL values of draw usign the break points obtained using cases where class1=0.

SELECT IF class1=0.

SORT CASES BY draw. * Number cases and calculate number of cases. COMPUTE nb=$casenum. RANK draw /n INTO n.

* In next line, change the number 10 by the number you need. COMPUTE #delta=n/(10-.0001).

* balance of paragraph finds the cut off points. COMPUTE flag=TRUNC(nb/#delta). AGGREGATE /OUTFILE=* /BREAK=flag /cut_off = FIRST(draw).

* prepare cut off points data for merger with main data file. FLIP VARIABLES=cut_off. COMPUTE dummy=1. SAVE OUTFILE='cutoff points.sav'.

*add cut_off points to original data file. GET FILE='temp.sav'. MATCH FILES /FILE=* /TABLE='C:\Program Files\SPSS\cutoff points.sav' /BY dummy.

DEFINE !rank_it (vname=!TOKENS(1) /nb_bins=!TOKENS(1)) VECTOR cutoff=var001 TO !CONCAT('var',!nb_bins). COMPUTE rank1=1. LOOP #cnt=2 TO !nb_bins. COMPUTE rank1=rank1 + (!vname>cutoff(#cnt)). END LOOP. EXECUTE. !ENDDEFINE.

* Note: in the macro calls, the argument of nb_bins must have 3 characters, eg for 5 use 005, for 15 use 015, etc. !rank_it vname=draw nb_bins=010 .

HTH Raynald Levesque rlevesque@videotron.ca

----- Original Message ----- From: S. Zitzer <sallyz@U.WASHINGTON.EDU> Newsgroups: bit.listserv.spssx-l To: <SPSSX-L@LISTSERV.UGA.EDU> Sent: Tuesday, June 13, 2000 10:00 AM Subject: feasibility question

> Hi, > > I have a user who wants to find percentile cutpoints for a lot of > variables using one group of cases, then recode that group plus the rest > of her data into categories using those cutpoints. I told her Frequencies > would give her the cutpoints. She wanted to know if there were an easier > way to do the RECODES than manually editing a syntax file as she has lots > of variables. Does anyone have any ideas? > > Thanks, > > Sally > Univ. of Washington, Seattle, WA, USA


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