Removing trailing Xs and dashes from data

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

Liz
Posts: 4
Joined: Tue Jan 20, 2009 10:28 am

Removing trailing Xs and dashes from data

Postby Liz » Thu Jan 22, 2009 10:45 am

Hi,

In the hospital data I am analysing, some of the values have an X or a dash at the end of them. These characters are not essential for my analysis and are making programming difficult, so I’d like to remove them.

Some examples of values as they are now and how I'd like them to be transformed are:

C20X C20
I48X I48
X791X X791
A62- A62
C220- C220
V031- V031

I understand this is doable in Excel, so I presume SPSS can remove trailing Xs and dashes, but have no idea how to go about it. I’d appreciate any help people can give with the syntax.

Thanks in anticipation and kind regards,

Liz
Liz
Posts: 4
Joined: Tue Jan 20, 2009 10:28 am

Postby Liz » Thu Jan 22, 2009 11:19 am

Hi,

I've worked out how to remove the dashes, using the following syntax:

string newdiag (A6).
compute newdiag = RTRIM(diag3, '-').
execute.

But when I tried to do the same for the Xs (sometimes a code has X- on the end, so I need to remove the dashes first then the Xs), using the same syntax (see below) it gave no error messages but didn't remove the Xs.

string newerdiag (A6).
compute newerdiag = RTRIM(newdiag, 'X').
execute.

Can anyone see what I'm doing wrong in the second bit of code?

Thanks.

Liz

Who is online

Users browsing this forum: No registered users and 1 guest

cron