"find and replace" for valuelabels as function in Syntax

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Statistik-Hans
Posts: 1
Joined: Thu Sep 29, 2011 2:18 pm

"find and replace" for valuelabels as function in Syntax

Postby Statistik-Hans » Thu Sep 29, 2011 2:24 pm

Hello,

I'm looking for a how to "find and replace" parts of valuelabels as a function in the Syntax.

For example, I want to replace all "u" trough "ue" in all value labels.
Is there a funtion oder something like that which I can use. I don't want to use the dialogue box, because it has to be written in the Syntax.

Thank you very much for help,
Hans
JonPedersen
Posts: 117
Joined: Wed May 25, 2011 7:07 am
Contact:

Re: "find and replace" for valuelabels as function in Syntax

Postby JonPedersen » Mon Oct 10, 2011 8:52 am

Hi,
I guess this should do the trick

(Assume that the variable YESNO exists and is 1 Yes, 2 No)


string LabelVar (A60).
compute LabelVar=VALUELABEL(YESNO).
if LabelVar="No" LabelVar="Maybe".
autorecode LabelVar /into YESMAYBE.

you can of course do more complex things with the value labels, using the appropriate string functions.
Note that this often will not retain the original order of your values, though. If that is important you probably need to use Python.
best
Jon

Who is online

Users browsing this forum: No registered users and 3 guests

cron