Posts filed under '5. Coding SPSS Syntax'
One of the many questions we got the last few days was from Dana. Dana asked us a question about combining two variables into one:
“Hello, I need to essentially combine two variables that have been
standardized into one new variable. Data that is present in one variable
is missing on the other and vice versa. I tried making a new variable and
then recoding missing data so it would pull in the values from the other
variable. Can you only recode missing values into numbers, or can I pull
an entirely different variable into it? Basically, how do I combine two
variables into one? Is there an easier way? Thanks!”
April 10th, 2007
andris
Today, Aleksandar sent us the following question:
“I’m having problems to recode system missing values to 0 with syntax
editor. How can I do that?”
In SPSS Syntax, missing values can be addressed via the keywords “sysmis” or “missing”. For this explanation we assume that in addition to the values 1 and 2, there are also values 3 and 4 which are defined as missing values. Please find some syntax below and an explanation of what they do. var2 stands for the variable name we are recoding.
RECODE var2 (missing = 3).
December 7th, 2006
andris
This week we got a question from Timo.
Is it possible to use syntax when recoding variables? For example, if I
had a variable that included the following values:
Ladybird
Bluebird
Elm
Butterfly
and I wanted to recode any values that included ‘bird’ into a new value
‘bird’, can I do this with the Recode transformation?
To solve to problem the following syntax is an option:
DATA LIST LIST /var1(A15).
BEGIN DATA
Bluebird
Ladybird
Birdwatcher
Butterfly
Elm
END DATA.
STRING newVar(A15).
DO IF INDEX(UPCASE(var1),”BIRD”) > 0 .
- COMPUTE newVar=”BIRD”.
END IF.
EXECUTE.
August 17th, 2006
mark
I am also writing webpages, and code (X)HTML and PHP by hand. If you code by hand, any code, and also SPSS syntax code, than it is very usefull to have syntax highlighting. Syntax highlighting is a feature of text / code editors that highlights or colourises code. By colourizing code you can very easily recognise types of code.
This is a preview of Coding editor with SPSS syntax highlighting
. Read the full post (177 words, estimated 42 secs reading time)
March 20th, 2006
andris