Replace a numeric fields value with it's value label

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

Replace a numeric fields value with it's value label

Mark Webb-5

Can this be done via syntax?

I.e. Value = 1 Value label = Yes

Can the 1 be replaced with Yes and the field changed to string?

Regards


-- 
Mark Webb

Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 

Skype       tomarkwebb 
Email       [hidden email] 
===================== 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: Replace a numeric fields value with it's value label

John F Hall

Why would you want to do that?  It seems OK as is.  Numerical values are much more efficient than strings.  Tables will be displayed with Yes, but if you don’t want the 1 just change your SPSS settings to Labels only.

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Webb
Sent: 26 November 2016 08:20
To: [hidden email]
Subject: Replace a numeric fields value with it's value label

 

Can this be done via syntax?

I.e. Value = 1 Value label = Yes

Can the 1 be replaced with Yes and the field changed to string?

Regards



-- 
Mark Webb
 
Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 
 
Skype       tomarkwebb 
Email       [hidden email] 

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Replace a numeric fields value with it's value label

Mark Webb-5

The SPSS syntax function to do this is VALUELABEL.

My data [5 columns of brands] are string and I want to sort alphabetically within respondent. The within case sort syntax I have uses numeric logic. So I autocode the 5 columns - then sort on the numeric values - then I want to get back to the string values which are now sorted. The VALUELABEL function does this.

Regards

Mark Webb

Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 

Skype       tomarkwebb 
Email       [hidden email] 
On 2016/11/26 10:58 AM, John F Hall wrote:

Why would you want to do that?  It seems OK as is.  Numerical values are much more efficient than strings.  Tables will be displayed with Yes, but if you don’t want the 1 just change your SPSS settings to Labels only.

 

From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Mark Webb
Sent: 26 November 2016 08:20
To: [hidden email]
Subject: Replace a numeric fields value with it's value label

 

Can this be done via syntax?

I.e. Value = 1 Value label = Yes

Can the 1 be replaced with Yes and the field changed to string?

Regards



-- 
Mark Webb
 
Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 
 
Skype       tomarkwebb 
Email       [hidden email] 

===================== 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

===================== 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: Replace a numeric fields value with it's value label

John F Hall

Not sure if you can do: RECODE <var to var> 1 = ‘Yes’.  If the 1 is a string you have to write:  RECODE <var to var> ‘1’ = ‘Yes’.  If it’s been changed to numeric you may have to use ALTER TYPE first.

 

A crafty way is to highlight the columns in Data View and use CTRL+H to change 1 to Yes.

 

John F Hall (Mr)

[Retired academic survey researcher]

 

Email:   [hidden email] 

Website: www.surveyresearch.weebly.com

SPSS start page:  www.surveyresearch.weebly.com/1-survey-analysis-workshop

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Webb
Sent: 26 November 2016 10:07
To: [hidden email]
Subject: Re: Replace a numeric fields value with it's value label

 

The SPSS syntax function to do this is VALUELABEL.

My data [5 columns of brands] are string and I want to sort alphabetically within respondent. The within case sort syntax I have uses numeric logic. So I autocode the 5 columns - then sort on the numeric values - then I want to get back to the string values which are now sorted. The VALUELABEL function does this.

Regards

Mark Webb
 
Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 
 
Skype       tomarkwebb 
Email       [hidden email] 

On 2016/11/26 10:58 AM, John F Hall wrote:

Why would you want to do that?  It seems OK as is.  Numerical values are much more efficient than strings.  Tables will be displayed with Yes, but if you don’t want the 1 just change your SPSS settings to Labels only.

 

From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Mark Webb
Sent: 26 November 2016 08:20
To: [hidden email]
Subject: Replace a numeric fields value with it's value label

 

Can this be done via syntax?

I.e. Value = 1 Value label = Yes

Can the 1 be replaced with Yes and the field changed to string?

Regards



-- 
Mark Webb
 
Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 
 
Skype       tomarkwebb 
Email       [hidden email] 

===================== 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

 

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Replace a numeric fields value with it's value label

Mark Webb-5
In reply to this post by Mark Webb-5

Look at the VALUELABELS function. It does what I require. Thanks for the responses.


On Sat, 26 Nov 2016 14:35 Timothy Hennigar, <[hidden email]> wrote:

If your data set in SPSS is fully defined now (with value labels) – why not save translate to excel saving value labels and re-read into spss

 

 

 

Thanks!

 

*********************************

Notice: This e-mail and any attachments may contain confidential and privileged information.  If you are not the intended recipient, please notify the sender immediately by return e-mail, do not use the information, delete this e-mail and destroy any copies.  Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal.  Email transmissions cannot be guaranteed to be secure or error free. The sender therefore does not accept any liability for errors or omissions in the contents of this message that arise as a result of email transmissions.

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Webb
Sent: Saturday, November 26, 2016 2:20 AM


To: [hidden email]
Subject: Replace a numeric fields value with it's value label

 

Can this be done via syntax?

I.e. Value = 1 Value label = Yes

Can the 1 be replaced with Yes and the field changed to string?

Regards



-- 
Mark Webb
 
Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 
 
Skype       tomarkwebb 
Email       [hidden email] 

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Replace a numeric fields value with it's value label

Art Kendall
is this it?
* make up some data.
new file.
data list list/id(f2) inBrand1 to inBrand4(4a3).
begin data
1 'aaa' 'bbb' 'ccc' 'ddd'
2 'ddd' 'ccc' 'bbb' 'ddd'
3 'aaa' 'ccc' 'ccc'
4 'fff' 'ggg' 'aaa' '+++'
5 'ddd' '888' 'ccc' 'aaa'
6 'DDD' 'AAA' 'aaa' 'ddd'
end data.
dataset name original.
list.
begin program.
import spss, spssaux2
spssaux2.rankvarsincase("inBrand1 inBrand2 inBrand3 inBrand4")
end program.
* change ranks to Descending.
recode inBrand1_rank to inBrand4_rank (0=4)(1=3)(2=2)(3=1) into D_rank1 to D_rank4.
formats D_rank1 to D_rank4 (f1).
String outBrand1 to outBrand4(a3).
vector     sourcevar  = InBrand1 to InBrand4.
vector    rankvar      = D_rank1 to D_rank4.
vector   outvar       = outBrand1 to outBrand4.
loop #i = 1 to 4.
compute outvar(#i) = sourcevar(rankvar(#i)).
end loop.
list variables = InBrand1 to InBrand4 outBrand1 to outBrand4 D_rank1 to D_rank4.




Art Kendall
Social Research Consultants