Date: Thu, 3 Jan 2008 08:50:33 -0800
Reply-To: Albert-jan Roskam <fomcl@yahoo.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Albert-jan Roskam <fomcl@yahoo.com>
Subject: Re: How create value lables?
In-Reply-To: <E08B564BAA29FE4F8EC8BAF42FE0A01F0209CF6E@bubsex02.cen.csin.cz>
Content-Type: text/plain; charset=iso-8859-1
...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 <JSpousta@CSAS.CZ> 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:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Julia
> Sent: Wednesday, January 02, 2008 9:39 PM
> To: SPSSX-L@LISTSERV.UGA.EDU
> 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 LISTSERV@LISTSERV.UGA.EDU (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
> LISTSERV@LISTSERV.UGA.EDU (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
LISTSERV@LISTSERV.UGA.EDU (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
|