psysky
psysky

Reputation: 3195

code missing values for many/all variables at once

Suppose i have such table enter image description here

if i use syntax to indicate missing values for variables, i must for each variable write something like

if missing (s1) s1=999.
MISSING VALUES s1 (999).
exe

if missing (s20) s20=999.
MISSING VALUES s20 (999).
exe

and so on.

but if i have 100 variables it will long and difficult. is it possible to inditace missing values at once for all vars in my data something like?

   if missing (s1-q35) s1-q35=999.



   MISSING VALUES s1-q35 (999).
    exe

Upvotes: 1

Views: 287

Answers (1)

eli-k
eli-k

Reputation: 11360

You can use recode like this:

recode s1 s2 s3 s4 s5 s6 .... q1 q2 q3 q4 q5 ..... (miss=999).

If some of your variables are consecutive in the data you can use "to". For example:

recode s1 to s21 q1 to q35 (miss=999).

If they are all consecutive you can use to for all of them:

missing values s1 to q35 (999). 

Upvotes: 2

Related Questions