BookmarkSubscribeRSS Feed
Ranjeeta
Pyrite | Level 9

 

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

8 REPLIES 8
ballardw
Super User

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;
Ranjeeta
Pyrite | Level 9
thankyou for pointing that out then how do I combine he two conditions in the array
novinosrin
Tourmaline | Level 20

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; 
Reeza
Super User
You're also missing an END for your DO statement. Or you can not have a DO statement at all.
Astounding
PROC Star

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".

Ranjeeta
Pyrite | Level 9

 

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;

 

Astounding
PROC Star

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'?

Ranjeeta
Pyrite | Level 9
They are codes that we need to exclude due to business requirements but thankyou there was extra parentheses in the code below its resolved now

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 789 views
  • 3 likes
  • 5 in conversation