defining decimal number in a recoded variable via syntax

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

defining decimal number in a recoded variable via syntax

Sanchez, Edgar
Greetings:

 

            I am trying to figure how to define the number of decimal
values allowed. I can easily do this via the User Interface but I am
trying to set up syntax in preparation for data analysis. Below is my
syntax:

 

RECODE Q_9_10_0_0 (CONVERT) ('a'=777) (b:'=888) ('c'=999) ('d'=000)
(MISSING=666) ("e"=1) (f=2) (g=3) INTO Q_9_10_0_0R.

VARIABLE LABELS  Q_9_10_0_0R 'Question 9_10 recoded'.

EXECUTE.

 

 

I am actually a SAS user but I have to get far more familiar with SPSS
than what I learned in grad school for work so your help is really
appreciated!

 

 

Edgar I Sanchez, Ph.D.

 

[hidden email]

http://www.apqceducation.org/

====================To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: defining decimal number in a recoded variable via syntax

Richard Ristow
At 03:48 PM 5/23/2008, Sanchez, Edgar wrote:

>             I am trying to figure how to define the number of
> decimal values allowed. I can easily do this via the User Interface
> but I am trying to set up syntax in preparation for data analysis.
> Below is my syntax:
>
>RECODE Q_9_10_0_0 (CONVERT) ('a'=777) (b:'=888) ('c'=999) ('d'=000)
>(MISSING=666) ("e"=1) (f=2) (g=3) INTO Q_9_10_0_0R.
>
>VARIABLE LABELS  Q_9_10_0_0R 'Question 9_10 recoded'.

I'm not sure what you mean by the "number of decimal values allowed"
-- number of decimal digits displayed? number of different numerical
values a variable can have? If the former, see the FORMATS command;
or, accept the default F8.2, which can display integers up to 5
digits. If the latter, SPSS uses the same number representation as
does SAS, with 53 bits of precision, able to represent all integers
up to 2**31-1. (But I doubt you meant that.)

Anyway, to start with, you have some syntax errors. I'll start by
reformatting your RECODE, then correct and comment. Your have (reformatted),

>RECODE Q_9_10_0_0
>    (CONVERT)
>    ('a'=777) (b:'=888) ('c'=999) ('d'=000)
>    (MISSING=666)
>    ("e"=1)   (f=2)     (g=3)
>       INTO Q_9_10_0_0R.

Correcting the syntax (see the 3rd and 5th lines of the statement),

RECODE Q_9_10_0_0
    (CONVERT)
    ('a'=777) ('b'=888) ('c'=999) ('d'=000)
    (MISSING=666)
    ("e"=1)   ('f'=2)   ('g'=3)
       INTO Q_9_10_0_0R.

So, your data includes some strings that represent numeric values,
and can also include values 'a', 'b', 'c', 'd', 'e', and 'f'.

Then,
. If your new variable is always an integer, you might like to specify
FORMATS        Q_9_10_0_0R (F4).
so it'll display as an integer.

. "(MISSING=666)" has no effect unless you've specified user-missing
values for variable Q_9_10_0_0. (See command MISSING VALUES.) In
SPSS, blank is not automatically a missing value for a string variable.
   You can always specify "(' ' = 666"), if that's what you mean.
   If you want to code all missing values as 6667, you probably want
to include statement
MISSING VALUES Q_9_10_0_0R (666).
as well.

And, how near does this come to answering what you wanted to ask?

-Best of luck,
  Richard

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: defining decimal number in a recoded variable via syntax

Sanchez, Edgar
Richard,

     I appreciate the reply. I indeed did mean the formats. Someone else pointed me in the right direction and I was able to figure out the formats command already. In regards to lacking of quotes that was actually a mistake on my part when i transfered the code over. To make it easier an example to read i removed the full labels and replaced them with single letters. in the process i created some syntax errors.

Your comment about the missing values was much appreciated because i hadn't thought about that. the actual values are most likely being copied from excel or access. I had originally created the code to import from access  but i am unconvinced that this is the best approach to take. I need to look at how blanks are transmitted. I assumed it was being transmitted as a null value (ie empty fields and therefore not " " which is a single space) hence the missing option.I appreciate the food fro thought and the detailed help!

Edgar


-----Original Message-----
From: SPSSX(r) Discussion on behalf of Richard Ristow
Sent: Fri 5/23/2008 6:21 PM
To: [hidden email]
Subject:      Re: defining decimal number in a recoded variable via syntax
 
At 03:48 PM 5/23/2008, Sanchez, Edgar wrote:

>             I am trying to figure how to define the number of
> decimal values allowed. I can easily do this via the User Interface
> but I am trying to set up syntax in preparation for data analysis.
> Below is my syntax:
>
>RECODE Q_9_10_0_0 (CONVERT) ('a'=777) (b:'=888) ('c'=999) ('d'=000)
>(MISSING=666) ("e"=1) (f=2) (g=3) INTO Q_9_10_0_0R.
>
>VARIABLE LABELS  Q_9_10_0_0R 'Question 9_10 recoded'.

I'm not sure what you mean by the "number of decimal values allowed"
-- number of decimal digits displayed? number of different numerical
values a variable can have? If the former, see the FORMATS command;
or, accept the default F8.2, which can display integers up to 5
digits. If the latter, SPSS uses the same number representation as
does SAS, with 53 bits of precision, able to represent all integers
up to 2**31-1. (But I doubt you meant that.)

Anyway, to start with, you have some syntax errors. I'll start by
reformatting your RECODE, then correct and comment. Your have (reformatted),

>RECODE Q_9_10_0_0
>    (CONVERT)
>    ('a'=777) (b:'=888) ('c'=999) ('d'=000)
>    (MISSING=666)
>    ("e"=1)   (f=2)     (g=3)
>       INTO Q_9_10_0_0R.

Correcting the syntax (see the 3rd and 5th lines of the statement),

RECODE Q_9_10_0_0
    (CONVERT)
    ('a'=777) ('b'=888) ('c'=999) ('d'=000)
    (MISSING=666)
    ("e"=1)   ('f'=2)   ('g'=3)
       INTO Q_9_10_0_0R.

So, your data includes some strings that represent numeric values,
and can also include values 'a', 'b', 'c', 'd', 'e', and 'f'.

Then,
. If your new variable is always an integer, you might like to specify
FORMATS        Q_9_10_0_0R (F4).
so it'll display as an integer.

. "(MISSING=666)" has no effect unless you've specified user-missing
values for variable Q_9_10_0_0. (See command MISSING VALUES.) In
SPSS, blank is not automatically a missing value for a string variable.
   You can always specify "(' ' = 666"), if that's what you mean.
   If you want to code all missing values as 6667, you probably want
to include statement
MISSING VALUES Q_9_10_0_0R (666).
as well.

And, how near does this come to answering what you wanted to ask?

-Best of luck,
  Richard

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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

====================To manage your subscription to SPSSX-L, send a message to
[hidden email] (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