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 (October 2007)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 26 Oct 2007 16:10:41 -0400
Reply-To:     Richard Ristow <wrristow@mindspring.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Richard Ristow <wrristow@mindspring.com>
Subject:      Re: Code: Value to Missing
Comments: To: Ribeiro <ribeirocanada@YAHOO.CA>
Comments: cc: Spousta Jan <JSpousta@CSAS.CZ>
In-Reply-To:  <200710260242.l9PMobGV026797@mailgw.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 10:42 PM 10/25/2007, Ribeiro wrote:

>>What should I use to inform that a value is missing at the code! >> >>compute nouv(#var)=sysmis.

As Jan Spousta wrote, it's

>compute nouv(#var) = $sysmis.

Now, you have (with that correction, some reformatting, and drop the EXECUTE),

>vector vector=v1 to v53/nouv(53,f8.0). >loop #var=1 to 53. >. do if vector(#var)=0. >. compute nouv(#var)=0. >. else if vector(#var)=5. >. compute nouv(#var)=sysmis. >. else. >. compute nouv(#var)=1. >. end if. >end loop.

Alternatively, try this:

RECODE v1 to v53 (0 = 0) (5 = SYSMIS) (ELSE = 1) INTO nouv1 TO nouv53. FORMATS nouv1 TO nouv53 (F8.0).

(Use "sysmis", not "$sysmis", in RECODE.)

Here's a demo, with 5 elements instead of 53. This is SPSS 14 draft output (WRR:not saved separately):

|-----------------------------|---------------------------| |Output Created |26-OCT-2007 16:07:17 | |-----------------------------|---------------------------| CaseID v1 v2 v3 v4 v5

001 2 1 4 1 1 002 5 4 4 3 1 003 1 2 0 5 3 004 0 2 5 0 5 005 2 1 0 4 2 006 5 3 1 1 4

Number of cases read: 6 Number of cases listed: 6

RECODE v1 to v5 (0 = 0) (5 = SYSMIS) (ELSE = 1) INTO nouv1 TO nouv5. FORMATS nouv1 TO nouv5 (F8.0).

LIST.

List |-----------------------------|---------------------------| |Output Created |26-OCT-2007 16:08:55 | |-----------------------------|---------------------------| CaseID v1 v2 v3 v4 v5 nouv1 nouv2 nouv3 nouv4 nouv5

001 2 1 4 1 1 1 1 1 1 1 002 5 4 4 3 1 . 1 1 1 1 003 1 2 0 5 3 1 1 0 . 1 004 0 2 5 0 5 0 1 . 0 . 005 2 1 0 4 2 1 1 0 1 1 006 5 3 1 1 4 . 1 1 1 1

Number of cases read: 6 Number of cases listed: 6 =================== APPENDIX: Test data =================== * ................................................................. . * ................. Test data ..................... . SET RNG = MT /* 'Mersenne twister' random number generator */ . SET MTINDEX = 3004 /* Providence, RI telephone book */ .

INPUT PROGRAM. . NUMERIC CaseID (N3). . LEAVE CaseID. . NUMERIC v1 TO v5 (F2). . LOOP CaseID = 1 TO 6. . VECTOR v = v1 TO v5. . LOOP #IX = 1 TO 5. . COMPUTE v(#IX) = TRUNC(RV.UNIFORM(0,6)). . END LOOP. . END CASE. . END LOOP. END FILE. END INPUT PROGRAM. LIST.

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