How create value lables?

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

How create value lables?

Julia-30
Hi,

A data file has tow varsibles: ServiceCodeID, ServiceDescription. I would
like to convert ServiceDescription to value lables of ServiceCodeID. Could
someone please advice how to do that?  Thanks!

=====================
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: How create value lables?

Spousta Jan
Hi Julia,

Try this old-fashioned but working solution (you may perhaps change lengths of variables and / or path in the syntax):

* create an example dataset.
data list list /ServiceCodeID (f1) ServiceDescription (a20).
begin data.
1 cleaning
2 cooking
3 ironing
end data.

* BEGIN OF THE SOLUTION SYNTAX:         .

* create and save a syntax file.
temp.
string s (a60).
compute s = ltrim(concat(string(ServiceCodeID, f3), " '", rtrim(ServiceDescription),"'")).
do if ($casenum = 1).
- compute s = concat("value labels ServiceCodeID ", s).
else.
- compute s = concat("  ", s).
end if.
WRITE OUTFILE='C:\temp\labels.sps' TABLE /s .
EXECUTE.

* apply the syntax and delete the auxiliary file.
INSERT FILE='C:\temp\labels.sps' SYNTAX=BATCH ERROR=STOP .
ERASE FILE='C:\temp\labels.sps'.

* END OF THE SOLUTION.

Best regards

Jan

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Julia
Sent: Wednesday, January 02, 2008 9:39 PM
To: [hidden email]
Subject: How create value lables?

Hi,

A data file has tow varsibles: ServiceCodeID, ServiceDescription. I would like to convert ServiceDescription to value lables of ServiceCodeID. Could someone please advice how to do that?  Thanks!

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



_____

Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

-.- --

=====================
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: How create value lables?

Albert-Jan Roskam
...And this is my (newbie, but working) Python
solution:

* create an example dataset.
data list list /ServiceCodeID (f1) ServiceDescription
(a20).
begin data
1 cleaning
2 cooking
3 ironing
end data.

begin program.
import spssaux
pos_source = 1          # fill in the position of the
source variable here
pos_target = 2          # fill in the position of the
target variable here
GetValueLabels = {}
GetVariableValues = []
GetValueLabels = spssaux.getValueLabels(pos_source -
1, matchtype=False)
GetVariableValues =
spssaux.getVariableValues(pos_target - 1,
missing=True)
for i in range(len(GetVariableValues)):
        GetValueLabels [i] = GetVariableValues [i]
        spss.Submit("add value labels ServiceCodeID %r
'%s'." % (i + 1, GetValueLabels[i]))
end program.

Cheers!!!
Albert-Jan

--- Spousta Jan <[hidden email]> wrote:

> Hi Julia,
>
> Try this old-fashioned but working solution (you may
> perhaps change lengths of variables and / or path in
> the syntax):
>
> * create an example dataset.
> data list list /ServiceCodeID (f1)
> ServiceDescription (a20).
> begin data.
> 1 cleaning
> 2 cooking
> 3 ironing
> end data.
>
> * BEGIN OF THE SOLUTION SYNTAX:         .
>
> * create and save a syntax file.
> temp.
> string s (a60).
> compute s = ltrim(concat(string(ServiceCodeID, f3),
> " '", rtrim(ServiceDescription),"'")).
> do if ($casenum = 1).
> - compute s = concat("value labels ServiceCodeID ",
> s).
> else.
> - compute s = concat("  ", s).
> end if.
> WRITE OUTFILE='C:\temp\labels.sps' TABLE /s .
> EXECUTE.
>
> * apply the syntax and delete the auxiliary file.
> INSERT FILE='C:\temp\labels.sps' SYNTAX=BATCH
> ERROR=STOP .
> ERASE FILE='C:\temp\labels.sps'.
>
> * END OF THE SOLUTION.
>
> Best regards
>
> Jan
>
> -----Original Message-----
> From: SPSSX(r) Discussion
> [mailto:[hidden email]] On Behalf Of Julia
> Sent: Wednesday, January 02, 2008 9:39 PM
> To: [hidden email]
> Subject: How create value lables?
>
> Hi,
>
> A data file has tow varsibles: ServiceCodeID,
> ServiceDescription. I would like to convert
> ServiceDescription to value lables of ServiceCodeID.
> Could someone please advice how to do that?  Thanks!
>
> =====================
> 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
>
>
>
> _____
>
> Tato zpráva a v¹echny pøipojené soubory jsou dùvìrné
> a urèené výluènì adresátovi(-ùm). Jestli¾e nejste
> oprávnìným adresátem, je zakázáno jakékoliv
> zveøejòování, zprostøedkování nebo jiné pou¾ití
> tìchto informací. Jestli¾e jste tento mail dostali
> neoprávnìnì, prosím, uvìdomte odesilatele a sma¾te
> zprávu i pøilo¾ené soubory. Odesilatel nezodpovídá
> za jakékoliv chyby nebo opomenutí zpùsobené tímto
> pøenosem.
>
> This message and any attached files are confidential
> and intended solely for the addressee(s). Any
> publication, transmission or other use of the
> information by a person or entity other than the
> intended addressee is prohibited. If you receive
> this in error please contact the sender and delete
> the message as well as all attached documents. The
> sender does not accept liability for any errors or
> omissions as a result of the transmission.
>
> -.- --
>
> =====================
> 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
>



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs

=====================
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: How create value lables?

Fry, Jonathan B.
In reply to this post by Spousta Jan
Let me count the easy ways...

1.   In the Data Editor's variable view, copy the labels cell from one and paste into the other's label cell.

2.   The Data->Copy Data Properties wizard, which produces syntax like

APPLY DICTIONARY
  /FROM *
  /SOURCE VARIABLES= ServiceCodeID
  /TARGET VARIABLES= ServiceDescription
  /VARINFO VALLABELS=REPLACE.

3.   The Data->Define Variable Properties wizard (although it copies all properties from one variable to another, not just the value labels).

Jonathan Fry
SPSS Inc.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Spousta Jan
Sent: Thursday, January 03, 2008 7:26 AM
To: [hidden email]
Subject: Re: How create value lables?

Hi Julia,

Try this old-fashioned but working solution (you may perhaps change lengths of variables and / or path in the syntax):

* create an example dataset.
data list list /ServiceCodeID (f1) ServiceDescription (a20).
begin data.
1 cleaning
2 cooking
3 ironing
end data.

* BEGIN OF THE SOLUTION SYNTAX:         .

* create and save a syntax file.
temp.
string s (a60).
compute s = ltrim(concat(string(ServiceCodeID, f3), " '", rtrim(ServiceDescription),"'")).
do if ($casenum = 1).
- compute s = concat("value labels ServiceCodeID ", s).
else.
- compute s = concat("  ", s).
end if.
WRITE OUTFILE='C:\temp\labels.sps' TABLE /s .
EXECUTE.

* apply the syntax and delete the auxiliary file.
INSERT FILE='C:\temp\labels.sps' SYNTAX=BATCH ERROR=STOP .
ERASE FILE='C:\temp\labels.sps'.

* END OF THE SOLUTION.

Best regards

Jan

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Julia
Sent: Wednesday, January 02, 2008 9:39 PM
To: [hidden email]
Subject: How create value lables?

Hi,

A data file has tow varsibles: ServiceCodeID, ServiceDescription. I would like to convert ServiceDescription to value lables of ServiceCodeID. Could someone please advice how to do that?  Thanks!

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



_____

Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

-.- --

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