此代码选择针对存储诊断代码的多个列(此处为DX1,DX2,DX3 ......等)选择诊断范围(此处范围为7567至75679)的情况。以下工作,但每次我正在寻找新的诊断范围时,更改代码是很痛苦的。如何缩短代码?
IF (RANGE(DX1,'7567','75679') | RANGE(DX2,'7567','75679') | RANGE(DX3,'7567','75679') | RANGE(DX4,'7567','75679') | RANGE(DX5,'7567','75679') | RANGE(DX6,'7567','75679') | RANGE(DX7,'7567','75679') |RANGE(DX8,'7567','75679')
| RANGE(DX9,'7567','75679') | RANGE(DX10,'7567','75679') | RANGE(DX11,'7567','75679') | RANGE(DX12,'7567','75679') | RANGE(DX13,'7567','75679') | RANGE(DX14,'7567','75679') | RANGE(DX15,'7567','75679')
| RANGE(DX16,'7567','75679') | RANGE(DX17,'7567','75679') | RANGE(DX18,'7567','75679') | RANGE(DX19,'7567','75679') | RANGE(DX20,'7567','75679') | RANGE(DX21,'7567','75679') | RANGE(DX22,'7567','75679') | RANGE(DX23,'7567','75679')
| RANGE(DX24,'7567','75679') | RANGE(DX25,'7567','75679'))ABDWALDEF=1.
EXECUTE.
答案 0 :(得分:1)
count ABDWALDEF= DX1 to DX25 ('7567' thru'75679').
exe.
if ABDWALDEF>1 ABDWALDEF=1.
exe.
就个人而言,我不会在SPSS中推荐字符串范围。您只需要确保知道自己在做什么,因为字符串范围与数值范围不同:
以代码756780为例:
正如评论中提到的@ eli-k,您确定要使用numerica范围,而不是字符串范围:
如果所有代码都是文本格式的数字,那么您也可以 将它们更改为数字,一切都变得更容易:
alter type DX1 to DXn (f10).