automatic variable recode?

automatic variable recode?

Post by David Brak » Thu, 17 Jul 2003 19:14:31



I have a variable with seven possible values and I would like to
recode it into a new variable so 1-3=1-3 and 4-7 = 4. I can do this as
a one-off creating a new summary variable, but each time I add new
cases, it seems I have to delete the new summary variable and
re-create it. Is there any way to tell SPSS that whenever I add a case
it should calculate a value for the new variable as well (as I could
in Excel?) I am using SPSS v. 11

P.S. Are there popular web-based fora where SPSS support also takes
place?

Thanks in advance for your help.

 
 
 

automatic variable recode?

Post by Bruce Weave » Thu, 17 Jul 2003 22:30:18



> I have a variable with seven possible values and I would like to
> recode it into a new variable so 1-3=1-3 and 4-7 = 4. I can do this as
> a one-off creating a new summary variable,

I assume you're creating the new variable with something
like this:

recode oldvar
  (4 thru 7 = 4)
  (else=copy) into newvar.
exe.
crosstabs
  /table = oldvar by newvar.

After a recode like that, I always crosstabulate the old and
new variables just to check that I did the recode correctly.

Also, as Art Kendall has pointed out in the past, it is good
practice to recode INTO a new variable rather than into the
same variable.  That way, if you do make an error, it is
easy to fix the problem.

Quote:> but each time I add new
> cases, it seems I have to delete the new summary variable and
> re-create it. Is there any way to tell SPSS that whenever I add a case
> it should calculate a value for the new variable as well (as I could
> in Excel?) I am using SPSS v. 11

The SPSS data window looks somewhat like a spreadsheet, but
does not work the same way.  You cannot store formulae in
the cells of an SPSS data file--the results of the
computations are stored there.

If you use the PASTE button instead of OKAY, and save your
work in a syntax file, when new cases are added to the file,
you can simply rerun your syntax to apply the recodes and
computations to the new cases.

Quote:

> P.S. Are there popular web-based fora where SPSS support also takes
> place?

> Thanks in advance for your help.

If you mean other discussion groups, I don't know of any.
If you mean SPSS resources in general, check out Raynald
Levesque's page:

  http://pages.infinit.net/rlevesqu/

Some other good sites are listed on my Stats page under
Resources for SPSS Users.

Cheers,
Bruce
--
Bruce Weaver

www.angelfire.com/wv/bwhomedir/

 
 
 

automatic variable recode?

Post by David Brak » Fri, 18 Jul 2003 01:20:14





>>Is there any way to tell SPSS that whenever I add a case
>> it should calculate a value for the new variable as well (as I could
>> in Excel?) I am using SPSS v. 11

>If you use the PASTE button instead of OKAY, and save your
>work in a syntax file, when new cases are added to the file,
>you can simply rerun your syntax to apply the recodes and
>computations to the new cases.

That's the ticket! That's exactly what I needed. I didn't really grasp
using the internal language until now. Is there any way to set the
characteristics of the new variables at the same time (eg making them
ordinal with no decimal places and width of 1 and setting the right
labels for values?) Don't worry too much if there isn't - it's easy
enough to paste in the variable view.

Anyhow, your quick and helpful answer is surely an example of the best
of what the Internet has to offer. Thank you!
David Brake, MSc student, New Media, Information & Society at London School of Economics & Political Science

Also see http://davidbrake.org/ (home page) and http://blog.org/ (weblog)

 
 
 

automatic variable recode?

Post by Bruce Weave » Fri, 18 Jul 2003 01:39:06






>>>Is there any way to tell SPSS that whenever I add a case
>>>it should calculate a value for the new variable as well (as I could
>>>in Excel?) I am using SPSS v. 11

>>If you use the PASTE button instead of OKAY, and save your
>>work in a syntax file, when new cases are added to the file,
>>you can simply rerun your syntax to apply the recodes and
>>computations to the new cases.

> That's the ticket! That's exactly what I needed. I didn't really grasp
> using the internal language until now. Is there any way to set the
> characteristics of the new variables at the same time (eg making them
> ordinal with no decimal places and width of 1 and setting the right
> labels for values?) Don't worry too much if there isn't - it's easy
> enough to paste in the variable view.

I never worry too much about specifiying the scaling of
mynumeric variables.  But its not hard to do.  Try this:

VARIABLE LEVEL varlist ORDINAL. /* or SCALE, or NOMINAL .
FORMAT varlist (f1.0).

VALUE LABELS varlist
  1     'value for 1'
  2     'value for 2'
  3     'value for 3' .

If you have string variables to format, it goes like this:

format string1 (a8).  /* string 8 characters wide.
format string2 (a15). /* string 15 characters wide.

And to add VARIABLE LABELS:

VARIABLE LABELS
  v1 'Variable 1'
  v2 'Variable 2'.

A lot of this sort of info can be found by clicking on
Help/Topics/Index.  The tricky bit is that you sometimes
have to have a fair bit of knowledge of SPSS to know what
search term to enter.

Quote:> Anyhow, your quick and helpful answer is surely an example of the best
> of what the Internet has to offer. Thank you!

My pleasure.

Cheers,
Bruce
--
Bruce Weaver

www.angelfire.com/wv/bwhomedir/