Prev: Interesting finding: Proc SQL create quoted name dataset!
Next: Interesting finding: Proc SQL create quoted name dataset!
From: Trish Bous on 26 Jan 2010 19:17 The data are numeric: Hi All, I am having some problems selecting a substring of data, and I was hoping someone might have some insight on the problem. I am trying to select ICD-9 codes. My code works successfully in other datasets, but I am not able to select my observations in the below dataset and I am not sure why. My code that works on other datasets is as follows: data z.NMSC; set z.namc94; tag = 0; array prx (3) diag1-diag3; do i = 1 to 3; if substr (prx {i}, 1, 3) in ('171', '172') then tag = 1; end; run; In the dataset described below, the code does not select any observations. However, if I change the code to the below, I select a few observations, but not the entire set I want: data z.NMSC; set z.namc94; tag = 0; array prx (3) diag1-diag3; do i = 1 to 3; if prx{i} in ('172100', '172110') then tag = 1; end; run; Any help on the problem? As a work around, I could list all possible codes in the (), but there has to be a better way. Dataset: 26 DIAG1 Num 8 27 DIAG2 Num 8 Example of data: Obs DIAG1 DIAG2 DIAG3 1 172100 147790 900000 2 202509 900000 900000 3 184490 140190 144390 4 159900 207000 900000 5 172110 900000 900000 6 143590 900000 900000 7 141490 141390 900000 8 156400 145580 140190 9 147390 137230 149390 10 173530 147790 900000 11 149600 116200 900000 12 171900 100880 118500 Thank you! |