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
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
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.
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'
@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.
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!
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.