A problem in transforming a string

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

Erikyo
Posts: 28
Joined: Mon Mar 30, 2009 8:20 pm

A problem in transforming a string

Postby Erikyo » Fri Aug 10, 2012 3:18 pm

Hi all,

I was faced with a problem transforming a few string variables to numeric (Ordinal). I've tackeled this pretty easily with the following syntax :
RECODE Q19 Q20A Q20B
("1,"="1")
("2,"="2")
("3,"="3")
("4,"="4")
("5,"="5")
("6,"="6")
("7,"="7")
("8,"="8")
("9,"="9")
("10,"="10")
("99,"="99").

I don't know how the comas got there, old datas. Anyway. Now I've got a much bigger problem with a similar string variable, to give you a little idea, here's a very small sample of my datas :

1098
1098,
1099
110
1100
11000
1101
1101,

You guys understand the magnitude of the problem? I don't know how to get rid of all those comas located at different positions. I could do it simply with a 'find and replace' but with a syntax? Can anyone help me?
Penguin_Knight
Posts: 473
Joined: Thu Apr 05, 2012 5:58 pm

Re: A problem in transforming a string

Postby Penguin_Knight » Fri Aug 10, 2012 7:12 pm

Code: Select all

STRING  newvar (A8).
COMPUTE newvar=REPLACE(oldvar, ",", "").
EXECUTE.
Erikyo
Posts: 28
Joined: Mon Mar 30, 2009 8:20 pm

Re: A problem in transforming a string

Postby Erikyo » Fri Aug 10, 2012 7:48 pm

Working fine !! Thanks so much !!!

Who is online

Users browsing this forum: No registered users and 1 guest

cron