Converting Value Labels to Numeric Values

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

Converting Value Labels to Numeric Values

Barry
Hello,

I've got several data sets to merge; they each have a 'wave' variable which
is numeric, having value labels which give the date of the wave (usually a
month-year).  The value labels are different in the different data sets
(e.g., a value of 1 has a different value label in data set A than in data
set B).

I'd like to set up a date variable and put the value label into it as the
value.  I've not been able to find anything referencing this.

Could somebody please point me to some examples?

Thanks,
Barry

=====================
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: Converting Value Labels to Numeric Values

Rick Oliver-3
data list free /var1 (f1).
begin data
1 2 3
end data.
value labels var1 1 '1/1/11' 2 '2/5/11' 3 '3/15/11'.
string #temp (a10).
compute #temp=valuelabel(var1).
compute datevar=number(#temp, adate10).
formats datevar (adate10).
list.



From:        Barry DeCicco <[hidden email]>
To:        [hidden email]
Date:        07/29/2011 01:58 PM
Subject:        Converting Value Labels to Numeric Values
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hello,

I've got several data sets to merge; they each have a 'wave' variable which
is numeric, having value labels which give the date of the wave (usually a
month-year).  The value labels are different in the different data sets
(e.g., a value of 1 has a different value label in data set A than in data
set B).

I'd like to set up a date variable and put the value label into it as the
value.  I've not been able to find anything referencing this.

Could somebody please point me to some examples?

Thanks,
Barry

=====================
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: Converting Value Labels to Numeric Values

Rick Oliver-3
In reply to this post by Barry
VALUELABEL function

VALUELABEL(varname). String. Returns the value label for the value of variable or an empty string if there is no label for the value. The value of varname must be a variable name; it cannot be an expression.

Example
STRING labelvar (A120).
COMPUTE labelvar=VALUELABEL(var1).




From:        Barry DeCicco <[hidden email]>
To:        [hidden email]
Date:        07/29/2011 01:58 PM
Subject:        Converting Value Labels to Numeric Values
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





Hello,

I've got several data sets to merge; they each have a 'wave' variable which
is numeric, having value labels which give the date of the wave (usually a
month-year).  The value labels are different in the different data sets
(e.g., a value of 1 has a different value label in data set A than in data
set B).

I'd like to set up a date variable and put the value label into it as the
value.  I've not been able to find anything referencing this.

Could somebody please point me to some examples?

Thanks,
Barry

=====================
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: Converting Value Labels to Numeric Values

Bruce Weaver
Administrator
In reply to this post by Barry
You said the value labels are "usually a month-year".  But what exactly do they look like?  Give some examples please.  The method Rick Oliver posted requires labels that are in a common date format, so it may need some tweaking, depending on what your value labels actually look like.


Barry DeCicco wrote
Hello,

I've got several data sets to merge; they each have a 'wave' variable which
is numeric, having value labels which give the date of the wave (usually a
month-year).  The value labels are different in the different data sets
(e.g., a value of 1 has a different value label in data set A than in data
set B).

I'd like to set up a date variable and put the value label into it as the
value.  I've not been able to find anything referencing this.

Could somebody please point me to some examples?

Thanks,
Barry

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Converting Value Labels to Numeric Values

Barry
In reply to this post by Barry
Here's my solution, from a combination of Rick Olliver's valuelabel command
and the SPSS date-time wizard.  It does depend on all value labels having
the same format (can't have 1 'Jul 08' and 2 'July, 2009).

STRING Wave_Label (A10).
COMPUTE Wave_Label=VALUELABEL(Wave).
COMPUTE Date=number(Wave_Label, MOYR6).
VARIABLE LABELS Date 'Date for this wave'.
VARIABLE LEVEL  Date (SCALE).
FORMATS Date (MOYR6).
VARIABLE WIDTH  Date(6).
EXECUTE.


On Fri, 29 Jul 2011 12:22:21 -0700, Bruce Weaver <[hidden email]>
wrote:

>You said the value labels are "usually a month-year".  But what exactly do
>they look like?  Give some examples please.  The method Rick Oliver posted
>requires labels that are in a common date format, so it may need some
>tweaking, depending on what your value labels actually look like.
>
>
>
>Barry DeCicco wrote:
>>
>> Hello,
>>
>> I've got several data sets to merge; they each have a 'wave' variable
>> which
>> is numeric, having value labels which give the date of the wave (usually a
>> month-year).  The value labels are different in the different data sets
>> (e.g., a value of 1 has a different value label in data set A than in data
>> set B).
>>
>> I'd like to set up a date variable and put the value label into it as the
>> value.  I've not been able to find anything referencing this.
>>
>> Could somebody please point me to some examples?
>>
>> Thanks,
>> Barry
>>
>> =====================
>> 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
>>
>
>
>-----
>--
>Bruce Weaver
>[hidden email]
>http://sites.google.com/a/lakeheadu.ca/bweaver/
>
>"When all else fails, RTFM."
>
>NOTE: My Hotmail account is not monitored regularly.
>To send me an e-mail, please use the address shown above.
>
>--
>View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Converting-Value-Labels-to-Numeric-Values-tp4648025p4648086.html
>Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
>=====================
>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