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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 823 views
  • 0 likes
  • 2 in conversation