BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hein68
Quartz | Level 8

Can you tell me what is wrong with this code?

 

*OTHER NEUROLOGICAL DISEASES;
array xx $ icdx1 icdx2 icdx3;
label ond="Oth neurological";
ond=0;
do over xx;
if xx in: ("B90", "D48", "G04", "G09", "G10", "G11", "G12",
"G13", "G24", "G25", "G26", "G32", "G37", "G51", "G52", "G53",
"G70", "G71", "G72", "G73", "G80", "G81", "G82", "G83", "G90",
"G91", "G93", "G95", "G99", "M47", "Q00", "Q01", "Q02", "Q03",
"Q04", "Q05", "Q06", "Q07", "Q76") then ond = 1;
*Doing exclusions in this way does not work;
if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732", "G733", "G734", "G838") then ond=0;
end;

 

The first part works fine.  But then when I add in the line of code under *Doing exclusions in this way does not work; I get the following error messages:

 

*Doing the exclusions in this way does not work;
509 if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732",
_
22
202
509 ! "G733", "G734", "G838") then ond=0;
ERROR 22-322: Syntax error, expecting one of the following: a quoted string,
a numeric constant, a datetime constant, a missing value,
iterator, (.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

510 end;

 

Please help!  Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @hein68,

 

Thanks for showing the log in a code box.

 

I think Reeza's advice, "Try typing it out," is the way to go*. I suspect that one of the blank characters, possibly that between '"G510",' and '"G732"' is not an ordinary space (ASCII code 32), but something else. I get the same error message if I use, e.g., a non-breaking space (ASCII code 160).

 

Unfortunately, even the code box conceals what is really there. For example, it seems to replace null bytes (ASCII code 00) with ordinary spaces. And it displays tabs (ASCII code 09) differently than your log window (advice: do not use tabs in code), which causes the underline character to appear at a misleading position. If I copy your log into my Enhanced Editor window, the relevant lines look like this:

62          if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732",
                                                                      _
                                                                      22
                                                                      202

 

* EDIT: Of course, you don't need to retype those alphanumeric strings. Just the (space?) character that is underlined in your log.

View solution in original post

11 REPLIES 11
Reeza
Super User
Are you copying and pasting that code? Try typing it out - specifically the quotation marks, looks like there's some smart quotes in there to me.
hein68
Quartz | Level 8
Thank you!!
ballardw
Super User

Data? Example data in the form of a working data step.

 

You should show an entire log of a complete data step or procedure. Copy the text from your log, on the forum open a text box by clicking on the </> icon above the message window an paste.

The text box will preserve formatting of things like the error message diagnostics. The _ character appeared in the place SAS identified the problem. The message windows on the forum will reformat pasted text. That means we don't see where SAS placed that character. It also means that depending on the actual problem that the message window may have removed the problem.

 

When I create some values and run the code I do not get that error:

1722  data junk;
1723     input a $;
1724     array xx $ a;
1725     do over xx;
1726     if xx in: ("B90", "D48", "G04", "G09", "G10", "G11", "G12",
1727     "G13", "G24", "G25", "G26", "G32", "G37", "G51", "G52", "G53",
1728     "G70", "G71", "G72", "G73", "G80", "G81", "G82", "G83", "G90",
1729     "G91", "G93", "G95", "G99", "M47", "Q00", "Q01", "Q02", "Q03",
1730     "Q04", "Q05", "Q06", "Q07", "Q76") then ond = 1;
1731     *Doing exclusions in this way does not work;
1732     if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732", "G733", "G734",
1732! "G838") then ond=0;
1733     end;
1734  datalines;

NOTE: The data set USER.JUNK has 5 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

But that was copying code from the message window as pasted.

PaigeMiller
Diamond | Level 26

*Doing the exclusions in this way does not work;
509 if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732",
_
22
202
509 ! "G733", "G734", "G838") then ond=0;
ERROR 22-322: Syntax error, expecting one of the following: a quoted string,
a numeric constant, a datetime constant, a missing value,
iterator, (.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

510 end;

 

BY showing us the log this way as plain text, the formatting of the log is destroyed and we cannot see where in the code the underline (in the third line of text above) is positioned. Instead, click on the </> icon and paste the log into the window that appears. This preserves the formatting of the log an enables us to see exactly where the error has occurred.

 

Oh yes, best practice is to show us the ENTIRE log for this data step, not just the errors. Please do that as well.

 

Please do both of the above for this question, and for all future questions.

--
Paige Miller
hein68
Quartz | Level 8

data out;
set temp;

*OTHER NEUROLOGICAL DISEASES;
array xx $ icdx1 icdx2 icdx3;
label ond="Oth neurological";
ond=0;
do over xx;
if xx in: ("B90", "D48", "G04", "G09", "G10", "G11", "G12",
"G13", "G24", "G25", "G26", "G32", "G37", "G51", "G52", "G53",
"G70", "G71", "G72", "G73", "G80", "G81", "G82", "G83", "G90",
"G91", "G93", "G95", "G99", "M47", "Q00", "Q01", "Q02", "Q03",
"Q04", "Q05", "Q06", "Q07", "Q76") then ond = 1;
*Doing exclusions in this way does not work;
if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732", "G733", "G734", "G838") then ond=0;
end;

run;

 

1 The SAS System 13:40 Tuesday, May 21, 2024

1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program';
4 %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5 %LET
5 ! _CLIENTPROJECTPATH='\\data.healthcare.uiowa.edu\research\icts\icts-dr
5 ! -chae-research\1682265_Chae\OVPR\SAS\pgm\csamlovpr.egp';
6 %LET _CLIENTPROJECTPATHHOST='NRSG-NB-412L';
7 %LET _CLIENTPROJECTNAME='csamlovpr.egp';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 %macro HTML5AccessibleGraphSupported;
15 %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
16 %mend;
17 FILENAME EGRTF TEMP;
18 ODS RTF(ID=EGRTF) FILE=EGRTF
19 ENCODING='utf-8'
20 STYLE=Journal
21 NOGTITLE
22 NOGFOOTNOTE
23 KEEPN
24 STARTPAGE=NO BODYTITLE
25 ;
NOTE: Writing RTF Body file: EGRTF
26 FILENAME EGPDF TEMP;
27 ODS PDF(ID=EGPDF) FILE=EGPDF STYLE=Journal NOTOC STARTPAGE=NO;
NOTE: Writing ODS PDF(EGPDF) output to DISK destination "EGPDF", printer "PDF".
28 FILENAME EGSR TEMP;
29 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
30 STYLE=HTMLBlue
31 NOGTITLE
32 NOGFOOTNOTE
33 GPATH=&sasworklocation
34 ENCODING=UTF8
35 options(rolap="on")
36 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
37 FILENAME EGXLSSX TEMP;
38 ODS EXCEL(ID=EGXLSSX) FILE=EGXLSSX STYLE=Excel
39 OPTIONS (
40 EMBEDDED_TITLES="yes" EMBEDDED_FOOTNOTES="yes"
41 );
42
43
44 data out;
45 set temp;
46
47 *OTHER NEUROLOGICAL DISEASES;
48 array xx $ icdx1 icdx2 icdx3;
49 label ond="Oth neurological";
50 ond=0;
51 do over xx;
52 if xx in: ("B90", "D48", "G04", "G09", "G10", "G11", "G12",
53 "G13", "G24", "G25", "G26", "G32", "G37", "G51", "G52", "G53",
54 "G70", "G71", "G72", "G73", "G80", "G81", "G82", "G83", "G90",
55 "G91", "G93", "G95", "G99", "M47", "Q00", "Q01", "Q02", "Q03",
56 "Q04", "Q05", "Q06", "Q07", "Q76") then ond = 1;
57 *Doing exclusions in this way does not work;
58 if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732",
_
22
202
58 ! "G733", "G734", "G838") then ond=0;
ERROR 22-322: Syntax error, expecting one of the following: a quoted string,
a numeric constant, a datetime constant, a missing value,
iterator, (.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

59 end;
60
61 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.OUT may be incomplete. When this step was stopped
there were 0 observations and 475 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.00 seconds

62
63 %LET _CLIENTTASKLABEL=;
64 %LET _CLIENTPROCESSFLOWNAME=;
65 %LET _CLIENTPROJECTPATH=;
66 %LET _CLIENTPROJECTPATHHOST=;
67 %LET _CLIENTPROJECTNAME=;
68 %LET _SASPROGRAMFILE=;
69 %LET _SASPROGRAMFILEHOST=;
70
71 ;*';*";*/;quit;run;
72 ODS _ALL_ CLOSE;
NOTE: ODS PDF(EGPDF) printed no output.
(This sometimes results from failing to place a RUN statement before the
ODS PDF(EGPDF) CLOSE statement.)
NOTE: Writing EXCEL(EGXLSSX) file:
C:\Users\mlhein\AppData\Roaming\SAS\EnterpriseGuide\EGTEMP\SEG-20684-fc692
816\contents\SAS Temporary Files\_TD4660_NRSG-NB-412L_\#LN00551
73
74
75 QUIT; RUN;
76

PaigeMiller
Diamond | Level 26

Showing us the log as plain text is not useful, it is not formatted in a useful way. We want to see the log formatted properly. Click on the </> icon and paste the log into the window that appears. I also asked for the ENTIRE log for the DATA step which has the error, not all of this other stuff.

--
Paige Miller
hein68
Quartz | Level 8

Here is the code I am using now.  The temp file is successfully created in another program:

 

data out;
	set temp;

	*OTHER NEUROLOGICAL DISEASES;
	array xx $ icdx1 icdx2 icdx3;
	label ond="Oth neurological";
	ond=0;
	do over xx;
	if xx in: ("B90", "D48", "G04", "G09", "G10", "G11", "G12",
	"G13", "G24", "G25", "G26", "G32", "G37", "G51", "G52", "G53",
	"G70", "G71", "G72", "G73", "G80", "G81", "G82", "G83", "G90",
	"G91", "G93", "G95", "G99", "M47", "Q00", "Q01", "Q02", "Q03",
	"Q04", "Q05", "Q06", "Q07", "Q76") then ond = 1;
	*Doing exclusions in this way does not work;
	if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732", "G733", "G734", "G838") then ond=0;
	end;

run;

And here is the SAS log:

1 The SAS System                                     13:40 Tuesday, May 21, 2024

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET
5        ! _
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         %macro HTML5AccessibleGraphSupported;
15             %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
16         %mend;
17         FILENAME EGRTF TEMP;
18         ODS RTF(ID=EGRTF) FILE=EGRTF
19             ENCODING='utf-8'
20             STYLE=Journal
21             NOGTITLE
22             NOGFOOTNOTE
23             KEEPN
24             STARTPAGE=NO BODYTITLE
25         ;
NOTE: Writing RTF Body file: EGRTF
26         FILENAME EGPDF TEMP;
27         ODS PDF(ID=EGPDF) FILE=EGPDF STYLE=Journal NOTOC STARTPAGE=NO;
NOTE: Writing ODS PDF(EGPDF) output to DISK destination "EGPDF", printer "PDF".
28         FILENAME EGSR TEMP;
29         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
30             STYLE=HTMLBlue
31             NOGTITLE
32             NOGFOOTNOTE
33             GPATH=&sasworklocation
34             ENCODING=UTF8
35             options(rolap="on")
36         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
37         FILENAME EGXLSSX TEMP;
38         ODS EXCEL(ID=EGXLSSX) FILE=EGXLSSX STYLE=Excel
39         OPTIONS (
40          EMBEDDED_TITLES="yes" EMBEDDED_FOOTNOTES="yes"
41         );
42         
43         
44         
45         
46         
47         
48         data out;
49         	set temp;
50         
51         	*OTHER NEUROLOGICAL DISEASES;
52         	array xx $ icdx1 icdx2 icdx3;
53         	label ond="Oth neurological";
54         	ond=0;
55         	do over xx;
56         	if xx in: ("B90", "D48", "G04", "G09", "G10", "G11", "G12",
57         	"G13", "G24", "G25", "G26", "G32", "G37", "G51", "G52", "G53",
58         	"G70", "G71", "G72", "G73", "G80", "G81", "G82", "G83", "G90",
59         	"G91", "G93", "G95", "G99", "M47", "Q00", "Q01", "Q02", "Q03",
60         	"Q04", "Q05", "Q06", "Q07", "Q76") then ond = 1;
61         	*Doing exclusions in this way does not work;
62         	if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732",
                                                                      _
                                                                      22
                                                                      202
62       ! "G733", "G734", "G838") then ond=0;
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, 
              a numeric constant, a datetime constant, a missing value, 
              iterator, (.  

ERROR 202-322: The option or parameter is not recognized and will be ignored.

63         	end;
64         
65         run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.OUT may be incomplete.  When this step was stopped 
         there were 0 observations and 475 variables.
WARNING: Data set WORK.OUT was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

66         
67         %LET _CLIENTTASKLABEL=;
68         %LET _CLIENTPROCESSFLOWNAME=;
69         %LET _CLIENTPROJECTPATH=;
70         %LET _CLIENTPROJECTPATHHOST=;
71         %LET _CLIENTPROJECTNAME=;
72         %LET _SASPROGRAMFILE=;
73         %LET _SASPROGRAMFILEHOST=;
74         
75         ;*';*";*/;quit;run;
76         ODS _ALL_ CLOSE;
NOTE: ODS PDF(EGPDF) printed no output. 
      (This sometimes results from failing to place a RUN statement before the 
      ODS PDF(EGPDF) CLOSE statement.)
NOTE: Writing EXCEL(EGXLSSX) file: 
      C:\Users\mlhein\AppData\Roaming\SAS\EnterpriseGuide\EGTEMP\SEG-20684-fc692
      816\contents\SAS Temporary Files\_TD4660_NRSG-NB-412L_\#LN01027
77         
78         
79         QUIT; RUN;
80         
FreelanceReinh
Jade | Level 19

Hello @hein68,

 

Thanks for showing the log in a code box.

 

I think Reeza's advice, "Try typing it out," is the way to go*. I suspect that one of the blank characters, possibly that between '"G510",' and '"G732"' is not an ordinary space (ASCII code 32), but something else. I get the same error message if I use, e.g., a non-breaking space (ASCII code 160).

 

Unfortunately, even the code box conceals what is really there. For example, it seems to replace null bytes (ASCII code 00) with ordinary spaces. And it displays tabs (ASCII code 09) differently than your log window (advice: do not use tabs in code), which causes the underline character to appear at a misleading position. If I copy your log into my Enhanced Editor window, the relevant lines look like this:

62          if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732",
                                                                      _
                                                                      22
                                                                      202

 

* EDIT: Of course, you don't need to retype those alphanumeric strings. Just the (space?) character that is underlined in your log.

hein68
Quartz | Level 8
Thank you! That worked 😊
Tom
Super User Tom
Super User

Looks like something strange is in your code.  SAS has placed the underscore under the middle of one of the quoted terms.

Tom_0-1716335368719.png

Did you accidentally include some backspace or cursor arrow keys into your program file?

Looks like perhaps you are using SAS/Studio to submit the code?  Perhaps there are some binary zeros or other strange things that take up bytes in the line of code, but are not reflected when the line is displayed that is causing the count of where to place the underscore to be off by a few bytes?

Patrick
Opal | Level 21

As others already wrote there is most likely some non-print character in your code that messes things up. It also appears that when you copy/paste this code into the forum then this character gets removed. 

In cases like yours first thing I'm often doing is to copy/paste such code or data into Notepad++ and look at it with View / Show Symbol / Show All Characters

I've just run below code without any issues.

data temp;
  length icdx1 icdx2 icdx3 $4;
  icdx1='G04';
  icdx3='G251';
run;

data out;
	set temp;
	*OTHER NEUROLOGICAL DISEASES;
	array xx $ icdx1 icdx2 icdx3;
	label ond="Oth neurological";
	ond=0;
	do over xx;
	if xx in: ("B90", "D48", "G04", "G09", "G10", "G11", "G12",
	"G13", "G24", "G25", "G26", "G32", "G37", "G51", "G52", "G53",
	"G70", "G71", "G72", "G73", "G80", "G81", "G82", "G83", "G90",
	"G91", "G93", "G95", "G99", "M47", "Q00", "Q01", "Q02", "Q03",
	"Q04", "Q05", "Q06", "Q07", "Q76") then ond = 1;
	*Doing exclusions in this way does not work;
	if xx in: ("G130", "G131", "G251", "G254", "G256", "G510", "G732", "G733", "G734", "G838") then ond=0;
	end;
run;

You will likely also need to amend your code because currently variable ond will get overwritten whenever one of the two conditions are met. 

If the value for icdx1 would lead to ond=1 but the value of icdx3 leads to ond=0 then ond will be 0. 

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
  • 11 replies
  • 761 views
  • 4 likes
  • 7 in conversation