removing spaces from string variables

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

removing spaces from string variables

Jill Adelson-2
We are trying to read an SPSS file into HLM v6.  It is not accepting the ID variables, and we think it is because they are string variables that have space in them.  The space are not in the same column for each case.  Does anyone know some code that we could use to remove spaces from them?

Thank you in advance,
Jill

--
Jill L. Adelson, Ph.D.
Assistant Professor
Educational Psychology, Measurement, and Evaluation Program
Educational and Counseling Psychology Department
College of Education and Human Development
University of Louisville

Reply | Threaded
Open this post in threaded view
|

Re: removing spaces from string variables

Jill Adelson-2
Nevermind - we solved the problem!

In case others have the problem, the syntax is

COMPUTE stringname = REPLACE(stringname, " ", "").

Thanks,
Jill

On Tue, Mar 22, 2011 at 3:53 PM, Jill Adelson <[hidden email]> wrote:
We are trying to read an SPSS file into HLM v6.  It is not accepting the ID variables, and we think it is because they are string variables that have space in them.  The space are not in the same column for each case.  Does anyone know some code that we could use to remove spaces from them?

Thank you in advance,
Jill

--
Jill L. Adelson, Ph.D.
Assistant Professor
Educational Psychology, Measurement, and Evaluation Program
Educational and Counseling Psychology Department
College of Education and Human Development
University of Louisville


Reply | Threaded
Open this post in threaded view
|

Re: [NEWSENDER] - removing spaces from string variables - Message is from an unknown sender

bdates
In reply to this post by Jill Adelson-2

I don’t know how large your file is, but if you paste the id’s into Excel and use the Replace function, your data will be converted to numeric and you can simply paste the new id’s back into the original dataset.

 

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jill Adelson
Sent: Tuesday, March 22, 2011 3:53 PM
To: [hidden email]
Subject: [NEWSENDER] - removing spaces from string variables - Message is from an unknown sender

 

We are trying to read an SPSS file into HLM v6.  It is not accepting the ID variables, and we think it is because they are string variables that have space in them.  The space are not in the same column for each case.  Does anyone know some code that we could use to remove spaces from them?

Thank you in advance,
Jill

--
Jill L. Adelson, Ph.D.
Assistant Professor
Educational Psychology, Measurement, and Evaluation Program
Educational and Counseling Psychology Department
College of Education and Human Development
University of Louisville

Reply | Threaded
Open this post in threaded view
|

Re: removing spaces from string variables

Bruce Weaver
Administrator
In reply to this post by Jill Adelson-2
You could use the REPLACE function.  E.g.,

data list list / ID (a10).
begin data
"K Pearson"
"ES Pearson"
"RF Fisher"
"JW Tukey"
"GEP Box"
end data.

string ID_no_spaces IDwith_ (a10).
compute ID_no_spaces = replace(ID," ","").
compute IDwith_ = replace(rtrim(ID)," ","_").
list.




Jill Adelson-2 wrote
We are trying to read an SPSS file into HLM v6.  It is not accepting the ID
variables, and we think it is because they are string variables that have
space in them.  The space are not in the same column for each case.  Does
anyone know some code that we could use to remove spaces from them?

Thank you in advance,
Jill

--
Jill L. Adelson, Ph.D.
Assistant Professor
Educational Psychology, Measurement, and Evaluation Program
Educational and Counseling Psychology Department
College of Education and Human Development
University of Louisville
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: [NEWSENDER] - Re: removing spaces from string variables - Message is from an unknown sender

bdates
In reply to this post by Jill Adelson-2

Thanks for cycling the solution back to everyone, Jill.

 

Brian

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jill Adelson
Sent: Tuesday, March 22, 2011 4:28 PM
To: [hidden email]
Subject: [NEWSENDER] - Re: removing spaces from string variables - Message is from an unknown sender

 

Nevermind - we solved the problem!

In case others have the problem, the syntax is

COMPUTE stringname = REPLACE(stringname, " ", "").

Thanks,
Jill

On Tue, Mar 22, 2011 at 3:53 PM, Jill Adelson <[hidden email]> wrote:

We are trying to read an SPSS file into HLM v6.  It is not accepting the ID variables, and we think it is because they are string variables that have space in them.  The space are not in the same column for each case.  Does anyone know some code that we could use to remove spaces from them?

Thank you in advance,
Jill

--
Jill L. Adelson, Ph.D.
Assistant Professor
Educational Psychology, Measurement, and Evaluation Program
Educational and Counseling Psychology Department
College of Education and Human Development
University of Louisville