recode into different variable help

recode into different variable help

Post by KerryDri » Fri, 18 Jul 2003 00:26:35



I'm hoping someone can help me.  I'm trying to recode a variable ( acb10a_1)
 into a different variable.......one that exists already (recode_1).  The
variable I am recoding is mostly missing data.......however, some cases have a
"1".  I want to recode those "1s" into "9s" into the variable recode_1.  The
database is structured in such a way that "recode_1" will originally have
missing data were I will want the recoded 9s to populate.  I have tried this
recode on similar variables and although I received a message indicating that
the recoded variable name already exists, it seemed to run fine.  When I am
trying it now on other variables, it appears to run, but there are no "9s" in
the recoded variable (recode_1) where there should be. This is the syntax I'm
using.  Can anyone help?  Thanks in advance.
RECODE
  acb10a_1
  ('1'=9)  INTO  recode_1 .
EXECUTE .
 
 
 

recode into different variable help

Post by Bruce Weave » Fri, 18 Jul 2003 01:22:12



> I'm hoping someone can help me.  I'm trying to recode a variable ( acb10a_1)
>  into a different variable.......one that exists already (recode_1).  The
> variable I am recoding is mostly missing data.......however, some cases have a
> "1".  I want to recode those "1s" into "9s" into the variable recode_1.  The
> database is structured in such a way that "recode_1" will originally have
> missing data were I will want the recoded 9s to populate.  I have tried this
> recode on similar variables and although I received a message indicating that
> the recoded variable name already exists, it seemed to run fine.  When I am
> trying it now on other variables, it appears to run, but there are no "9s" in
> the recoded variable (recode_1) where there should be. This is the syntax I'm
> using.  Can anyone help?  Thanks in advance.
> RECODE
>   acb10a_1
>   ('1'=9)  INTO  recode_1 .
> EXECUTE .

Why do you have quotes around the 1?  Is acb10a_1  string
variable?  If so, maybe there are leading or trailing
blanks--i.e., the actual value is '1 ' rather than '1'.  If
this is the problem, I'd probably use RTRIM and/or LTRIM in
an if statement...something like:

if RTRIM(acb10a_1) = '1' recode_1 = 9.

If acb10a_1 is not a string, try without the quotes.

Cheers,
Bruce
--
Bruce Weaver

www.angelfire.com/wv/bwhomedir/

 
 
 

1. Count of highest valued variable for each case and recoding to different value

Hi,

I'm not an experienced user of SPSS, especially not syntax, so I have
encountered some problems that I hope somebody can help me with. I have
searched the web but there seems to be nothing that can lead me in the
correct direction. The problems are:

1. I have 10 variables and 2001 cases. Each case have a value for each
variable from 0-10 with 11 and 12 coded missing. I need to make a count of
which variable, or variables if tied, each case values the highest. The
grand total for each variable is needed, not which cases that values the
variables. How can I write this in a syntax, since I think that would be the
correct method to use?

2. The same 10 variables and 2001 cases. Each case gives the values to the
variables. Now I have to give the lowest valued variable the score of 1,
second-lowest the score of 2 and so on, until the maximum of 10 for the
highest valued variable. Since each case doesn't necessarily value all
variables, I can't just recode as usual, instead I think I need to make some
syntax that can recode and count this, but how?

Any help, advice and suggestion will be welcome.

Thanks

Martin Ejnar Hansen

2. batch changing absolute to relative URLs

3. recoding a string variable into a numeric variable

4. New ITU G.729 standard: source code???

5. Help: recode date variables (newbie)

6. Get paid to review dinning

7. recoding variables

8. recoding sas variables with data in them

9. Recoding many continuous variables into discrete categories

10. automatic variable recode?

11. Help (Multiple files, different numbers of variables on each)

12. Recoding across variables in SPSS