I need to remove the decimal point from a string variable called
'Diagnosis' and have the new variable width = 5.
Any help on how to do this would be much appreciated.
Sample Data:
Diagnosis: Need it to look like:
009 009
481 481
592.4 5924
334.77 33477
V55.1 V551
(the decimal, if present, is always in the fourth column)
Thanks in advance for your help!
Sincerely,
Robin White,
Research Officer
Health Services Utilization and Research Commission
Saskatoon, SK, Canada
S7N 0W8
phone: (306) 655-6764
fax: (306) 655-1462
internet: whi...@sdh.sk.ca
http://www.sdh.sk.ca/hsurc/
J. Stone
I mocked up an example of your data problem, and the following SPSS syntax
did what you want. The original diagnosis variable is "diag", and the
new variable without the decimal place is "newdiag."
do if (index(diag,'.') = 4).
compute newdiag = concat( substr(diag,1,3), substr(diag,5) ).
else .
compute newdiag = diag.
end if .
Regards,
--
=-=-=-=-=-=-=-=-=-==-=-=-=
Mike Lacy, Sociology Dept., Colo. State Univ. FT COLLINS CO 80523
voice (970) 491-6721 fax (970) 491-2191
> I need to remove the decimal point from a string variable called
> 'Diagnosis' and have the new variable width = 5.
Try something like this:
DATA LIST LIST /dia (A6) .
BEGIN DATA
009
481
592.4
334.77
V55.1
Q.1234
Q1.234
Q12.34
Q123.4
END DATA .
/* If there is a dot the two parts of the diagnosis separated by the dot are
/* concatenated - if not the diagnosis is just copied to the new variable. As
/* you can see from the last four cases the dot doesn't have to be in the fourth
/*
column for things to work out.
STRING newdia (A5) .
DO IF INDEX(dia,".") GT 0 .
COMPUTE
newdia=CONCAT(SUBSTR(dia,1,INDEX(dia,".")-1),SUBSTR(dia,INDEX(dia,".")+1)).
ELSE .
COMPUTE newdia=dia .
END IF .
EXECUTE .
I hope this helps .
Rolf Kjoeller
===========================================
Rolf Kjoeller
e-mail: rolf_k...@vip.cybercity.dk
web: www2.dk-online.dk/users/rolf_kjoeller/front.htm
===========================================