recoding

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

recoding

saygili ayca
Hi all,

when we recode a variable into new variable, Is there
any limitation on number of coding?

Thanks




____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting
Reply | Threaded
Open this post in threaded view
|

Re: recoding

Noble, Lyndsay
You know, I can't think of a more efficient way than recoding, but 600
recodes seems daunting.  Maybe someone else on the list serve has an idea?

Lyndsay


-----Original Message-----
From: saygili ayca [mailto:[hidden email]]
Sent: Wednesday, July 18, 2007 9:48 AM
To: Noble, Lyndsay
Subject: RE: recoding

I appreciate if you know an efficient way:

There is a variable that contains drug name. But in
CRF it is open ended question. There are a lot of
miscoding error. We are trying to clean data by
recoding.  :))

--- "Noble, Lyndsay" <[hidden email]>
wrote:

> There might be a more efficient way of doing it than
> writing all of the
> recode statements.  What is the nature of the
> situation?
>
> Lyndsay
>
> -----Original Message-----
> From: saygili ayca [mailto:[hidden email]]
> Sent: Wednesday, July 18, 2007 1:20 AM
> To: Noble, Lyndsay
> Subject: RE: recoding
>
> thanx. we need around 600, that is why I asked. ---
> "Noble, Lyndsay" <[hidden email]> wrote:
>
> > Hi,
> > I've done up to around 70 and not had a problem.
> >
> > Lyndsay
> > -----Original Message-----
> > From: SPSSX(r) Discussion
> > [mailto:[hidden email]] On Behalf Of
> > saygili ayca
> > Sent: Tuesday, July 17, 2007 3:45 AM
> > To: [hidden email]
> > Subject: recoding
> >
> > Hi all,
> >
> > when we recode a variable into new variable, Is
> > there
> > any limitation on number of coding?
> >
> > Thanks
> >
> >
> >
> >
> >
>
_____________________________________________________________________________

> > _______
> > Building a website is a piece of cake. Yahoo!
> Small
> > Business gives you all
> > the tools to get online.
> > http://smallbusiness.yahoo.com/webhosting
> >
>
>
>
>
>
_____________________________________________________________________________
> _______
> Be a better Globetrotter. Get better travel answers
> from someone who knows.
> Yahoo! Answers - Check it out.
>
http://answers.yahoo.com/dir/?link=list&sid=396545469
>




_____________________________________________________________________________
_______
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for
today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
Reply | Threaded
Open this post in threaded view
|

Re: recoding

Graham Wright-2
We've done similar things like this in the following way (which may or
may not be appropriate in your case):
Sort the data by the string variable in question, so that all the valid
responses are at the top, then save a version of the dataset that only
has that variable and some sort of unique ID variable. Then open the new
file, make a new variable in the blank column next to the string
variable and then go down the list manually in the "data view" screen
and  just put a number equal to what you want the new category to be, so
next to "Asprin" and "asperin" put 1's and next to "Zoloft" and
"zolofft" put 2's or whatever. Then get rid of the column with the
string in it and merge this file (with just the ID var and the new
column) back into the original dataset (using "add variables" and "Match
cases on key variables" using the ID variable as the key) and you have a
new variable that is a recode of the original open ended question.

This way seems like a lot of work, but it actually goes pretty quickly
and I'm pretty sure it's faster than writing
"recode ("Asprin" "asperin" "Aasperin".....etc=1) ("Zoloft",
"zoloft...etc=2)" and having to retype everyone's answers. Plus you
don't run into any sort of limit on recode statements.


-Graham



Noble, Lyndsay wrote:

> You know, I can't think of a more efficient way than recoding, but 600
> recodes seems daunting.  Maybe someone else on the list serve has an idea?
>
> Lyndsay
>
>
> -----Original Message-----
> From: saygili ayca [mailto:[hidden email]]
> Sent: Wednesday, July 18, 2007 9:48 AM
> To: Noble, Lyndsay
> Subject: RE: recoding
>
> I appreciate if you know an efficient way:
>
> There is a variable that contains drug name. But in
> CRF it is open ended question. There are a lot of
> miscoding error. We are trying to clean data by
> recoding.  :))
>
> --- "Noble, Lyndsay" <[hidden email]>
> wrote:
>
>
>> There might be a more efficient way of doing it than
>> writing all of the
>> recode statements.  What is the nature of the
>> situation?
>>
>> Lyndsay
>>
>> -----Original Message-----
>> From: saygili ayca [mailto:[hidden email]]
>> Sent: Wednesday, July 18, 2007 1:20 AM
>> To: Noble, Lyndsay
>> Subject: RE: recoding
>>
>> thanx. we need around 600, that is why I asked. ---
>> "Noble, Lyndsay" <[hidden email]> wrote:
>>
>>
>>> Hi,
>>> I've done up to around 70 and not had a problem.
>>>
>>> Lyndsay
>>> -----Original Message-----
>>> From: SPSSX(r) Discussion
>>> [mailto:[hidden email]] On Behalf Of
>>> saygili ayca
>>> Sent: Tuesday, July 17, 2007 3:45 AM
>>> To: [hidden email]
>>> Subject: recoding
>>>
>>> Hi all,
>>>
>>> when we recode a variable into new variable, Is
>>> there
>>> any limitation on number of coding?
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>>
>>>
> _____________________________________________________________________________
>
>>> _______
>>> Building a website is a piece of cake. Yahoo!
>>>
>> Small
>>
>>> Business gives you all
>>> the tools to get online.
>>> http://smallbusiness.yahoo.com/webhosting
>>>
>>>
>>
>>
>>
>>
> _____________________________________________________________________________
>
>> _______
>> Be a better Globetrotter. Get better travel answers
>> from someone who knows.
>> Yahoo! Answers - Check it out.
>>
>>
> http://answers.yahoo.com/dir/?link=list&sid=396545469
>
>
>
>
>
> _____________________________________________________________________________
> _______
> Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for
> today's economy) at Yahoo! Games.
> http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
>
Reply | Threaded
Open this post in threaded view
|

Re: recoding

Daniel Robertson
In reply to this post by Noble, Lyndsay
Jon Peck has made a number of postings to the list in recent weeks about
using Python programmability for regular expression searches, which
would allow you to specify quite flexible 'fuzzy' matching criteria. You
might check the list archives. Here's an example:
<http://listserv.uga.edu/cgi-bin/wa?A2=ind0705&L=spssx-l&P=R14128>.
I suppose you could then put the match/replace code inside a loop and
iterate over the target variables and match terms.

hth,
Dan R.

Noble, Lyndsay wrote:

> You know, I can't think of a more efficient way than recoding, but 600
> recodes seems daunting.  Maybe someone else on the list serve has an idea?
>
> Lyndsay
>
>
> -----Original Message-----
> From: saygili ayca [mailto:[hidden email]]
> Sent: Wednesday, July 18, 2007 9:48 AM
> To: Noble, Lyndsay
> Subject: RE: recoding
>
> I appreciate if you know an efficient way:
>
> There is a variable that contains drug name. But in
> CRF it is open ended question. There are a lot of
> miscoding error. We are trying to clean data by
> recoding.  :))
>
> --- "Noble, Lyndsay" <[hidden email]>
> wrote:
>
>
>> There might be a more efficient way of doing it than
>> writing all of the
>> recode statements.  What is the nature of the
>> situation?
>>
>> Lyndsay
>>
>> -----Original Message-----
>> From: saygili ayca [mailto:[hidden email]]
>> Sent: Wednesday, July 18, 2007 1:20 AM
>> To: Noble, Lyndsay
>> Subject: RE: recoding
>>
>> thanx. we need around 600, that is why I asked. ---
>> "Noble, Lyndsay" <[hidden email]> wrote:
>>
>>
>>> Hi,
>>> I've done up to around 70 and not had a problem.
>>>
>>> Lyndsay
>>> -----Original Message-----
>>> From: SPSSX(r) Discussion
>>> [mailto:[hidden email]] On Behalf Of
>>> saygili ayca
>>> Sent: Tuesday, July 17, 2007 3:45 AM
>>> To: [hidden email]
>>> Subject: recoding
>>>
>>> Hi all,
>>>
>>> when we recode a variable into new variable, Is
>>> there
>>> any limitation on number of coding?
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>>
>>>
> _____________________________________________________________________________
>
>>> _______
>>> Building a website is a piece of cake. Yahoo!
>>>
>> Small
>>
>>> Business gives you all
>>> the tools to get online.
>>> http://smallbusiness.yahoo.com/webhosting
>>>
>>>
>>
>>
>>
>>
> _____________________________________________________________________________
>
>> _______
>> Be a better Globetrotter. Get better travel answers
>> from someone who knows.
>> Yahoo! Answers - Check it out.
>>
>>
> http://answers.yahoo.com/dir/?link=list&sid=396545469
>
>
>
>
>
> _____________________________________________________________________________
> _______
> Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for
> today's economy) at Yahoo! Games.
> http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
>
>

--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University, Ithaca NY 14853-2801
607.255.9642 / irp.cornell.edu
Reply | Threaded
Open this post in threaded view
|

Re: recoding

Peck, Jon
In reply to this post by Graham Wright-2
If you can use programmability, this kind of task is pretty susceptible to automation.  There are several tools available in Python or in SPSS Developer Central modules (www.spss.com.devcentral) that can help.  I'll note here just a few ideas.

-regular expressions to pick up patterns of the common misspellings.
-if you have a list of all the valid drug names, try spell correction based on
levenshteindistance: calculate similarity between two strings or even
soundex: calculate the soundex value of a string (a rough phonetic encoding)

simple Python code to look through lists and pick a new value.

The trans.py and extendedTransforms.py modules help you integrate this approach into SPSS transformations.

Putting programmability aside, you could check the values by applying the SPSS Data Validation module, which lets you define the valid answers.

HTH,
Jon Peck


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Graham Wright
Sent: Wednesday, July 18, 2007 12:13 PM
To: [hidden email]
Subject: Re: [SPSSX-L] recoding

We've done similar things like this in the following way (which may or
may not be appropriate in your case):
Sort the data by the string variable in question, so that all the valid
responses are at the top, then save a version of the dataset that only
has that variable and some sort of unique ID variable. Then open the new
file, make a new variable in the blank column next to the string
variable and then go down the list manually in the "data view" screen
and  just put a number equal to what you want the new category to be, so
next to "Asprin" and "asperin" put 1's and next to "Zoloft" and
"zolofft" put 2's or whatever. Then get rid of the column with the
string in it and merge this file (with just the ID var and the new
column) back into the original dataset (using "add variables" and "Match
cases on key variables" using the ID variable as the key) and you have a
new variable that is a recode of the original open ended question.

This way seems like a lot of work, but it actually goes pretty quickly
and I'm pretty sure it's faster than writing
"recode ("Asprin" "asperin" "Aasperin".....etc=1) ("Zoloft",
"zoloft...etc=2)" and having to retype everyone's answers. Plus you
don't run into any sort of limit on recode statements.


-Graham



Noble, Lyndsay wrote:

> You know, I can't think of a more efficient way than recoding, but 600
> recodes seems daunting.  Maybe someone else on the list serve has an idea?
>
> Lyndsay
>
>
> -----Original Message-----
> From: saygili ayca [mailto:[hidden email]]
> Sent: Wednesday, July 18, 2007 9:48 AM
> To: Noble, Lyndsay
> Subject: RE: recoding
>
> I appreciate if you know an efficient way:
>
> There is a variable that contains drug name. But in
> CRF it is open ended question. There are a lot of
> miscoding error. We are trying to clean data by
> recoding.  :))
>
> --- "Noble, Lyndsay" <[hidden email]>
> wrote:
>
>
>> There might be a more efficient way of doing it than
>> writing all of the
>> recode statements.  What is the nature of the
>> situation?
>>
>> Lyndsay
>>
>> -----Original Message-----
>> From: saygili ayca [mailto:[hidden email]]
>> Sent: Wednesday, July 18, 2007 1:20 AM
>> To: Noble, Lyndsay
>> Subject: RE: recoding
>>
>> thanx. we need around 600, that is why I asked. ---
>> "Noble, Lyndsay" <[hidden email]> wrote:
>>
>>
>>> Hi,
>>> I've done up to around 70 and not had a problem.
>>>
>>> Lyndsay
>>> -----Original Message-----
>>> From: SPSSX(r) Discussion
>>> [mailto:[hidden email]] On Behalf Of
>>> saygili ayca
>>> Sent: Tuesday, July 17, 2007 3:45 AM
>>> To: [hidden email]
>>> Subject: recoding
>>>
>>> Hi all,
>>>
>>> when we recode a variable into new variable, Is
>>> there
>>> any limitation on number of coding?
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>>
>>>
> _____________________________________________________________________________
>
>>> _______
>>> Building a website is a piece of cake. Yahoo!
>>>
>> Small
>>
>>> Business gives you all
>>> the tools to get online.
>>> http://smallbusiness.yahoo.com/webhosting
>>>
>>>
>>
>>
>>
>>
> _____________________________________________________________________________
>
>> _______
>> Be a better Globetrotter. Get better travel answers
>> from someone who knows.
>> Yahoo! Answers - Check it out.
>>
>>
> http://answers.yahoo.com/dir/?link=list&sid=396545469
>
>
>
>
>
> _____________________________________________________________________________
> _______
> Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for
> today's economy) at Yahoo! Games.
> http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
>
Reply | Threaded
Open this post in threaded view
|

Re: recoding

Art Kendall-2
In reply to this post by Noble, Lyndsay
Something like this untested syntax may be what you need.

If you have one or more string variables, you could AUTORECODE them into
a new set of variables

AUTORECODE VARIABLES= answer1 to answer7
 /INTO x1 to x7
 /GROUP
 /PRINT.

Then you could collapse some codes into a correctly spelled code.
recode x1 to x7 (1,3,4,11=4) (73, 74, 75 =74) (200 thru 205= 202)(else=copy) into y1 to y7.

Autorecode variables= y1 to y7
 /into z1 to z7
 /group
 /print.


Art Kendall
Social Research Consultants




Noble, Lyndsay wrote:

> You know, I can't think of a more efficient way than recoding, but 600
> recodes seems daunting.  Maybe someone else on the list serve has an idea?
>
> Lyndsay
>
>
> -----Original Message-----
> From: saygili ayca [mailto:[hidden email]]
> Sent: Wednesday, July 18, 2007 9:48 AM
> To: Noble, Lyndsay
> Subject: RE: recoding
>
> I appreciate if you know an efficient way:
>
> There is a variable that contains drug name. But in
> CRF it is open ended question. There are a lot of
> miscoding error. We are trying to clean data by
> recoding.  :))
>
> --- "Noble, Lyndsay" <[hidden email]>
> wrote:
>
>
>> There might be a more efficient way of doing it than
>> writing all of the
>> recode statements.  What is the nature of the
>> situation?
>>
>> Lyndsay
>>
>> -----Original Message-----
>> From: saygili ayca [mailto:[hidden email]]
>> Sent: Wednesday, July 18, 2007 1:20 AM
>> To: Noble, Lyndsay
>> Subject: RE: recoding
>>
>> thanx. we need around 600, that is why I asked. ---
>> "Noble, Lyndsay" <[hidden email]> wrote:
>>
>>
>>> Hi,
>>> I've done up to around 70 and not had a problem.
>>>
>>> Lyndsay
>>> -----Original Message-----
>>> From: SPSSX(r) Discussion
>>> [mailto:[hidden email]] On Behalf Of
>>> saygili ayca
>>> Sent: Tuesday, July 17, 2007 3:45 AM
>>> To: [hidden email]
>>> Subject: recoding
>>>
>>> Hi all,
>>>
>>> when we recode a variable into new variable, Is
>>> there
>>> any limitation on number of coding?
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>>
>>>
> _____________________________________________________________________________
>
>>> _______
>>> Building a website is a piece of cake. Yahoo!
>>>
>> Small
>>
>>> Business gives you all
>>> the tools to get online.
>>> http://smallbusiness.yahoo.com/webhosting
>>>
>>>
>>
>>
>>
>>
> _____________________________________________________________________________
>
>> _______
>> Be a better Globetrotter. Get better travel answers
>> from someone who knows.
>> Yahoo! Answers - Check it out.
>>
>>
> http://answers.yahoo.com/dir/?link=list&sid=396545469
>
>
>
>
>
> _____________________________________________________________________________
> _______
> Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for
> today's economy) at Yahoo! Games.
> http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
>
>
>