Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SYSMIS in IF command

1,556 views
Skip to first unread message

santc

unread,
Apr 30, 2013, 7:15:09 AM4/30/13
to
Hi,
I have a data set in which A1 is the age of person 1 and G1 is the gender. I would like to check if G1 is answered (1 or 2) then any data in A1 is missing. i write a syntax like this

compute check1=0.
if ((G1=1 or G1=2) AND A1=SYMIS) check1=1.
EXECUTE.
FREQUENCIES check1.

but it gives an error.

Can anybody help please.

Art Kendall

unread,
Apr 30, 2013, 7:56:03 AM4/30/13
to
take a look at the example syntax below.
Note that I changed the symbolic operator "=" to the conventional
operator "eq". Over the years I have seen many people confuse
themselves by not making this distinction.

Also why do you have sysmis in your data? A good data handling practice
is to redraft your syntax until there are no system missing values.
Again a result of having seen many people shoot themselves in the foot
by failing to do this.

*** if it is from poor syntax on reading that is easily fixed with the
SET command as in the second set of syntax.

*** If it is due to data transformations you should trap the condition
that results in an instruction the software cannot obey. Assign a user
missing value.
this is an example of a generic trap.
do if x lt 0 .
compute result = -99999.
else if missing(x).
compute result = -99998
else.
compute result= sqrt(x).
end if.
missing values result( lo thru -90000).
value labels result
-99999 'x was zero'
-99999 'x was missing'.

*** syntax for original post.

* with input data not yet clean.
new file.
data list list/ Id(f2) g1(f1)a1(f1).
begin data
01 1
02 2
03 1 1
04 1 1
end data.
compute check1=0.
if ((G1 eq 1 or G1 eq 2) AND A1=$SYsMIS) check1=1.
FREQUENCIES check1.


* with input data clean.
new file.
set blanks =0.
data list list/ Id(f2) g1(f1)a1(f1).
begin data
01 1
02 2
03 1 1
04 1 1
end data.
compute check1=0.
if ((G1 eq 1 or G1 eq 2) AND A1=0) check1=1.
FREQUENCIES check1.


Art Kendall
Social Research Consultants
Message has been deleted

santc

unread,
Apr 30, 2013, 10:44:55 AM4/30/13
to
Hi Art,
the following syntax didn't work

compute check1=0.
if ((G1 eq 1 or G1 eq 2) AND A1=$SYsMIS) check1=1.
FREQUENCIES check1.

But this one works

compute check1=0.
if ((G1 eq 1 or G1 eq 2) AND SYSMIS(A1)) check1=1.
FREQUENCIES check1.

I dont understand why!!

Art Kendall

unread,
Apr 30, 2013, 11:18:25 AM4/30/13
to
I just copied the example syntax and ran it again,
The only warnings or errors message I received were about the missing
values on input.

Paste the example syntax into a syntax window and run it.
Other than the messages about the input data what other messages do you get?

new file.
data list list/ Id(f2) g1(f1)a1(f1).
begin data
01 1
02 2
03 1 1
04 1 1
end data.
compute check1=0.
if ((G1 eq 1 or G1 eq 2) AND A1=$SYsMIS) check1=1.
FREQUENCIES check1.

Art Kendall
Social Research Consultants

Message has been deleted

santc

unread,
Apr 30, 2013, 11:34:25 AM4/30/13
to
That is true. But all values in Check1 are 0s.

Art Kendall

unread,
Apr 30, 2013, 11:54:51 AM4/30/13
to
MY ERROR.
I pasted in the wrong syntax page.

new file.
data list list/ Id(f2) g1(f1)a1(f1).
begin data
01 1
02 2
03 1 1
04 1 1
end data.
compute check1=0.
if ((G1 eq 1 or G1 eq 2) AND SYsMIS(a1)) check1=1.
FREQUENCIES check1.

Art Kendall
Social Research Consultants

Rich Ulrich

unread,
Apr 30, 2013, 3:45:26 PM4/30/13
to
On Tue, 30 Apr 2013 07:44:55 -0700 (PDT), santc <sant...@gmail.com>
wrote:

>Hi Art,
>the following syntax didn't work
>
>compute check1=0.
>if ((G1 eq 1 or G1 eq 2) AND A1=$SYsMIS) check1=1.
>FREQUENCIES check1.
>
>But this one works
>
>compute check1=0.
>if ((G1 eq 1 or G1 eq 2) AND SYSMIS(A1)) check1=1.
>FREQUENCIES check1.
>
>I dont understand why!!
>
...

The reason why SYSMIS( ) and MISS( ) are provided is because
SPSS doesn't like any logical comparison where a value is
missing (like $SYSMIS); and it "traps" for that first, ignoring
the designated comparison.

Therefore, never use $SYSMIS this way.


- And your "warning" on input will probably disappear if you
make sure that the line includes blanks at the end, enough of
them for the field that is supposed to be read. - Unfortunately,
some editors want to truncate blanks at the end of the line.
When you are reading in fixed format, you can easily remedy
the problem by putting some other character in a later column.


--
Rich Ulrich
0 new messages