BookmarkSubscribeRSS Feed
jbkm
Fluorite | Level 6

Hello,

 

I am executing this simple dataset:

 

data _null_ ; if 0 le 0   then call symputx('Result','OK') ; else call symputx('Result','NOK') ; run;

 

I am getting this error:

data _null_ ; if 0 le 0   then call symputx('Result','OK') ; else call symputx('Result','NOK') ; run;

_

388

76

ERROR 388-185: Expecting an arithmetic operator.

ERROR 76-322: Syntax error, statement will be ignored.

 

It looks like there are some hidden characters before 'then'. When I remove the first two blanks before 'then' it works.

 

Any clue what such a weird behaviour ?

 

Regards,

jbkm

5 REPLIES 5
KDG
SAS Employee KDG
SAS Employee

Did you cut and paste the code from another source? Alot of times an unprintable character will get picked up from the original text and throw an error. 


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

Tom
Super User Tom
Super User

Something you are submitting BEFORE the DATA statement is causing SAS to think it is just part of the earlier statement.

 

How are you running SAS?  Are you using some GUI interface to a SAS session? Like Enterprise Guide or SAS/Studio.  If so try resetting the session (or leaving the GUI and restarting it) to get a fresh session.

 

Are you using SAS Display Manager to use an interactive SAS session?

 

Are you running SAS by creating a text file with the program and running SAS from the command line?

 

Also check if there are syntax errors in your autoexec.sas file or if you are using EG or SAS/Studio the "prefix" code that those tools send before your code.

jbkm
Fluorite | Level 6

I am running my through EG.

To summarize the context, I upload data from an excel file and I format that data to get: 0 le 0, then I contruct my instruction to be run in a dataset:

rc = dosubl('data _null_ ; if ' || strip(NewVAlue) || ' then call symputx(''Result'',''OK'') ; else call symputx(''Result'',''NOK'') ; run;');

 

Here NewVAlue = '0 le 0'

Reeza
Super User
Excel likely has a line return or invisible space somewhere. Try using COMPRESS() with the modifier to remove blanks or COMPBL() if you can just remove all whitespace.
Tom
Super User Tom
Super User

@jbkm wrote:

I am running my through EG.

To summarize the context, I upload data from an excel file and I format that data to get: 0 le 0, then I contruct my instruction to be run in a dataset:

rc = dosubl('data _null_ ; if ' || strip(NewVAlue) || ' then call symputx(''Result'',''OK'') ; else call symputx(''Result'',''NOK'') ; run;');

 

Here NewVAlue = '0 le 0'


Aha.  So you are NOT running the code you showed originally.

It is hard to tell from your original post what part of the generated code SAS is complaining about. (Because you didn't use the Insert Code button on the forum editor to post the text).  But it looks like there is some hidden character at the end of the text in your NEWVALUE variable.

data _null_ ; if 0 le 0   then call symputx('Result','OK') ; else call symputx('Result','NOK') ; run;

Notice how it there appears to be two spaces before the word THEN.  Your statement would only generate one space before THEN.  So the extra blank space must be some other character.

Use the $HEX format to see what character it is and remove it.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1785 views
  • 2 likes
  • 4 in conversation