I am getting an error Can someone advise how to correct this step
data DAD_N_1;
set DAD_N_1a;
/* ARRAY - ISCHEMIC STROKE DIAGNOSIS CODE */
ARRAY DX_CODE [25] DIAG_CODE_01 - DIAG_CODE_25;
STROKE_CNT=0;
DO I=1 TO 25;
IF ARRAY DX_CODE[I] IN ('I63', 'I64', 'H34') THEN DO;
STROKE_CNT+1;
IF SUBSTR(DX_CODE[I],1,4) NOT IN ('I636')THEN DO;
STROKE_CNT+1;
/* COUNT NUMBER OF Ischemic stroke procedures */
run;
ERROR:
data DAD_N_1;
383 set DAD_N_1a;
384 /* ARRAY - ISCHEMIC STROKE DIAGNOSIS CODE */
385 ARRAY DX_CODE [25] DIAG_CODE_01 - DIAG_CODE_25;
386
387 STROKE_CNT=0;
388
389 DO I=1 TO 25;
390 IF ARRAY DX_CODE[I] IN ('I63', 'I64', 'H34') THEN DO;
-------
22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, /, ;, <, <=,
<>, =, >, ><, >=, AND, EQ, GE, GT, LE, LT, MAX, MIN, NE, NG, NL, OR, [, ^=, {, |, ||,
~=.
391 STROKE_CNT+1;
392 IF SUBSTR(DX_CODE[I],1,4) NOT IN ('I636')THEN DO;
393 STROKE_CNT+1;
394 /* COUNT NUMBER OF Ischemic stroke procedures */
395 run;
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
390:14 1:1
You only use the keyword array when defining one. Instead of
IF ARRAY DX_CODE[I] IN ('I63', 'I64', 'H34') THEN DO;
use
IF DX_CODE[I] IN ('I63', 'I64', 'H34') THEN DO;
Are you looking to do this??
if DX_CODE[I] IN ('I63', 'I64', 'H34') or SUBSTR(DX_CODE[I],1,4) NOT IN ('I636')THEN STROKE_CNT+1;
How could this possibly be the right logic?
IF SUBSTR(DX_CODE[I],1,4) NOT IN ('I636')THEN DO;
STROKE_CNT+1;
Even missing values for the diagnosis code would increase the stroke count.
Can diagnosis codes really be 3 characters long? If not, how could this ever produce a match:
IF ARRAY DX_CODE[I] IN ('I63', 'I64', 'H34') THEN DO;
You might have to explain what you are trying to count. Especially whether you are trying to double-count "I63" and "I636".
I am trying to count the procedures that have codes ('I61' 'I63' 'I64') ('H341') and not NOT IN ('G454' 'I636')
data DAD_N_1;
130 set DAD_N_1a;
131 /* ARRAY - ISCHEMIC STROKE DIAGNOSIS CODE */
132 ARRAY DX_CODE [25] DIAG_CODE_01 - DIAG_CODE_25;
133 STROKE_CNT=0;
134
135 DO I=1 TO 25;
136
137 IF((SUBSTR(DX_CODE[I],1,3) IN ('I61' 'I63' 'I64') OR SUBSTR(DX_CODE[I],1,4) = ('H341'))and
138 SUBSTR(DX_CODE[I],1,4) NOT IN ('G454' 'I636')
139 THEN STROKE_CNT+1;
----
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, &, ), <, <=, =, >, >=, AND, EQ, GE,
GT, IN, LE, LT, NE, NG, NL, NOT, NOTIN, OR, ^, ^=, |, ~, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
140
141 end;
142
143 /* COUNT NUMBER OF Ischemic stroke procedures */
144 run;
OK, last chance to explain. If you count the procedure codes that are in ('I61' 'I63' 'I64' 'H341'), why do you need to pay any attention to 'G454' and 'I636'?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.