Are the behaviors of the operators in expressions the same for SAS and CASL?
SAS
https://go.documentation.sas.com/doc/en/lrcon/9.4/p00iah2thp63bmn1lt20esag14lh.htm
CASL
https://go.documentation.sas.com/doc/en/pgmsascdc/v_042/caslpg/n1nlmx3yjfv9vrn1xykzhdfu7jgj.htm
Do they all work the same way in CASL and SAS consistently and to produce the same results? Can anyone confirm this?
The pages show there are some differences. I'm noticing that in CASL, for example the comparison operator Not Equal to is != but it doesn't work in CASL, it only works with mnemonics like NE, or I need to use the same operator as SAS which is ^=. Has anyone been able to get != to run in CASL?
Can you post an example CASL log of it "not working"? If it's in the documentation, but doesn't work I would regard that as a bug. What Viya version are you using?
I am using Viya 4.0
This doesn't work:
data casuser.cars;
set sashelp.cars;
keep Make Model Origin MSRP Type;
run;
proc cas;
table.fetch /
table = {name="cars",
caslib="casuser",
where = "Type != 'SUV' & MSRP>=75000"};
run;
quit;
ERROR: The WHERE clause 'Type != 'SUV' & MSRP>=75000' could not be parsed as written.
ERROR: Syntax error detected on line 2 at column 7. Found =, expecting a name, a quoted string, a numeric constant, a datetime
constant, a missing value, INPUT, PUT.
ERROR: Failure opening table 'cars'
ERROR: The action stopped due to errors.
It only works with ^= or NE
Sounds like the documentation page is wrong. != is not a valid way to specify the not equal operator. So don't use it in your code.
There is a FEEDBACK link on every documentation page. Click on that link and give SAS your feedback that the documentation page is wrong about how to code a not equal operator. They will get back to you very quickly.
I thought so since I had never been able to get != to work, but do you know if there are any other operator differences between SAS and CASL, where the operator works in one but not the other, or should they both be able to use the same operators and produce consistent results?
I have never seen using BANG (exclamation point) work as meaning NOT in SAS.
Perhaps it works in pure CASL code? But why use it when you can use something that is easier for others to understand. Such as the NE mnenomic or literally spelling out NOT.
1634 data test; 1635 A=1; B=2; 1636 /* Does nor work in SAS 1637 bang = ! (a = b); 1638 */ 1639 caret = a ^= b; 1640 tilde = a ~= b; 1641 mnemonic = a ne b ; 1642 not = not (a = b); 1643 run; NOTE: The data set WORK.TEST has 1 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.00 seconds 1644 1645 proc print; 1646 run; NOTE: There were 1 observations read from the data set WORK.TEST. NOTE: PROCEDURE PRINT used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
Result
Obs A B caret tilde mnemonic not 1 1 2 1 1 1 1
The SAS language "not equal" operators are listed as these:
The exclamation mark isn't included.
Yes but it doesn't work for me in CASL either, despite the documentation saying that. I am wondering if there are any differences between the operators in SAS and CASL.
If the SAS operators work in CASL (have you tried them?) as listed in my previous message then this is a documentation error. != definitely doesn't work in SAS 9.4.
The CASL operators documentation page shows != is a valid operator for CASL, but it doesn't show it in SAS 9.4.
I know that but have you tried the SAS not equal operators in CASL? I don't have Viya available to try.
In that case the CASL operators doc is in error and should show the same operators as the SAS doc.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.