BookmarkSubscribeRSS Feed
shoin
Lapis Lazuli | Level 10

(Hortonworks Hadoop accessed via SAS ACCESS/Hadoop, a Kerberos enviornment)

 

Are there any limitation using WHERE predicate in a PROC SQL statement.

 

Example:

proc sql;

  create table a as select *

    from hdp_tb.transact x

       where x.order  < 100 ;

 

I only get 0 obs.

 

If I break it

 

proc sql;

  create table a as select from hdp_tb.transact x

;

quit;

 

proc sql ;

   create table b as select from a

      where x.order  < 100 

;

quit;

 

I get obs, and vars returned.

 

What am i doing wrong or is there a limitation?  Is my construct in-correct?

 

Thank you for your input

 

S

 

2 REPLIES 2
Tom
Super User Tom
Super User

Not really clear what you are doing since your last query is referencing X, but doesn't define X.

 

One thing to note is the difference in how other systems handle missing values (what they refer to as NULL values).

 

In SAS all comparisons, like ORDER < 100, use binary logic.  They are either TRUE or FALSE.  To make this possible SAS treats missing numeric values is less than any valid numeric value.  So the test (. < 100) is TRUE.  And the test (. > 100) is FALSE.

 

But it other SQL implementations they use essentially tri-level logic.  The result can either be TRUE, FALSE or unknown.  So (null < 100) not TRUE.

 

So perhaps your data has missing values for ORDER.

 

Try

 where (x.order < 100) or (x.order is null)
shoin
Lapis Lazuli | Level 10

Thank you, the x.order (as you pointed out) is a typo.  I did not catch it and stand corrected.

 

The question is that the first sql where predicate brings 0 obs and in the second attempt; the 2 sql statements (for a moment ignore x.order and assume it is order < 100) it does bring back results.  I am only trying to find out as to why would that be.

 

TIA

 

S

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 850 views
  • 0 likes
  • 2 in conversation