Re: loop and do repeat problem with thousands of unique values to insert

Posted by Art Kendall on
URL: http://spssx-discussion.165.s1.nabble.com/loop-and-do-repeat-problem-with-thousands-of-unique-values-to-insert-tp4268902p4269202.html

from <help>

Overview (AUTORECODE command)

AUTORECODE recodes the values of string and numeric variables to consecutive integers and puts the recoded values into a new variable called a target variable. The value labels or values of the original variable are used as value labels for the target variable. AUTORECODE is useful for creating numeric independent (grouping) variables from string variables for procedures such as ONEWAY and DISCRIMINANT. AUTORECODE can also recode the values of factor variables to consecutive integers, which may be required by some procedures and which reduces the amount of workspace needed by some statistical procedures.


AUTORECODE VARIABLES=varlist
  /INTO new varlist
  [/BLANK={VALID**}
        {MISSING}
 [/GROUP]
  [/DESCENDING]
 [/PRINT]
if this will be applied to many files there are two more specifications that are possible.
 [/APPLY TEMPLATE=’filespec’]
 [/SAVE TEMPLATE=’filespec’]

if you want blanks to be labeled as missing you will need the /BLANK.

Art Kendall
Social Research Consultants

On 3/29/2011 2:59 AM, Maurice Vergeer wrote:
dear fellow list visitors,

please help me with this problem.
I have the following syntax which works perfectly.

It 'replaces' strings in old variables (name1 to name14) into
numerical ones in a new variable (newname1 to newname14).

example:
vector name=name1 to name14.
vector newname(14).
loop i=1 to 14.
do repeat a="alpha" "beta" "gamma" / b=1 2 3.
- if name(i) = a newname(i)=b.
end repeat print.
end loop.


However, instead of three values (alpha beta and gamma) I have
thousands of unique string values stored in a separate system file,
each identified with a unique numerical code.
How can I insert these values in the do repeat function (after 'a='
and after 'b=')?

The reason why I want to change these from string to numeric ones is
that I know the system file will be smaller and hopefully also faster
to read.

You help is much appreciated.

sincerely
Maurice




--
___________________________________________________________________
Maurice Vergeer
Department of communication, Radboud University�  (www.ru.nl)
PO Box 9104, NL-6500 HE Nijmegen, The Netherlands

Visiting Professor Yeungnam University, Gyeongsan, South Korea

Recent publications:
-Vergeer, M., Hermans, L., & Sams, S. (accepted for publication).
Online social networks and micro-blogging in political campaigning:
The exploration of a new campaign tool and a new campaign style. Party
Politics.
-Eisinga, R., Franses, Ph.H., & Vergeer, M. (2010). Weather conditions
and daily television use in the Netherlands, 1996–2005. International
Journal of Meteorology.

Webspace
www.mauricevergeer.nl
http://blog.mauricevergeer.nl/
www.journalisteninhetdigitaletijdperk.nl
maurice.vergeer (skype)
___________________________________________________________________

=====================
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
Art Kendall
Social Research Consultants