BookmarkSubscribeRSS Feed
PaalNavestad
Pyrite | Level 9

Hi. I am working with FEDSQL and date. I have a table of approx. 40 million rows where I want to do the following. If I run this without the and date >= date'2021-04-01' then it runs between 2.5 and 3 seconds (resultset is approx 650k rows). If I add the and date >= date'2021-04-01' the same query runs in just over 25 seconds. giving a slightly smaller result set. If i run with out the date filter and does the subset for the in a separate sas data step the subsequent datastep runs in apprx. 0.4 seconds. 

 

I created a track. Number is 

7613313278

 

Do i do something wrong? Can anybody please explain why?

 

proc fedsql sessref=casauto;
drop table casuser.WellProfileDays force;

create table casuser.WellProfileDays
as select

wellbore,
date,
Plant_cd,
Complex_cd,
Facility_nm,
bucket,
min(oil) as oil,
min(gas) as gas,
min(BOE) as boe
from std_production.STF_all_details_hist

where stf_case=&stf_case
and date >= date'2021-04-01'


group by
wellbore,
date,
Plant_cd,
Complex_cd,
Facility_nm,
bucket;

quit;

 

14 REPLIES 14
ChrisNZ
Tourmaline | Level 20

That an interesting question.

Please format your code by pasting it using the appropriate icon.

PaalNavestad
Pyrite | Level 9

No, FEDSQL does not recognize that. 

 

Kurt_Bremser
Super User

Next I would try to create a numeric literal:

%let cutoff=%sysfunc(inputn(2021-04-01,yymmdd10.));

and later

where stf_case=&stf_case
and date >= &cutoff

as I hope that dates in CAS are still counts of days from 1960-01-01.

qoit
Pyrite | Level 9
If it's just about the dates, FEDSQL, unlike PROC SQL, accepts all ANSI compliant datatypes, and therefore is processing all DOUBLE data type SAS dates against the FEDSQL date constant. It could be that SAS is converting the RHS equation date'2021-04-01' into DOUBLE data type to process each observation, and thereby pushing both CPU and Real time.
PaalNavestad
Pyrite | Level 9

Thanks, I thought about something like that. I used the numeric date but then I got another fault around comparing to integer. 

Kurt_Bremser
Super User

@PaalNavestad wrote:

Thanks, I thought about something like that. I used the numeric date but then I got another fault around comparing to integer. 


Please share the exact code you used.

PaalNavestad
Pyrite | Level 9

Hi Kurt,

this is the code I used

%let stf_case = '2+10_21';
%let FcstStart= '01mar2021'd;

data _null_;
	cutoff = &fcststart;
	call symput('cutoff',cutoff);
run;
This give
%put cutoff=&cutoff;
cutoff= 22340
However when running this is FEDSQL

seleect etc.

from std_production.STF_all_details_hist

where stf_case=&stf_case
and date >= &cutoff

I get
WARNING: Unable to choose a best candidate operator. You might need to add explicit typecasts.
ERROR: Operator is not unique: DATE >= INTEGER
ERROR: The action stopped due to errors.
ERROR: The FedSQL action was not successful
 
There is something in the syntax I do not understand.
 
But the real challenge is why when entering dateconstants as the system expect it there is a much larger run time.
 
SASKiwi
PROC Star

Looks like you are using a CAS library in Viya - what version are you using? Viya is evolving rapidly so you might find later versions perform better.

 

I suggest you open a Tech Support track on your findings and post the reply back here.

ChrisNZ
Tourmaline | Level 20

If you can't get an answer here, please contact SAS tech support. 

And do let us know about the outcome. I am most curious.

PaalNavestad
Pyrite | Level 9

Hi Chris, yes I will create a track

PaalNavestad
Pyrite | Level 9

Hi all, this is now a verified bug with SAS and will according to SAS most probable be fixed in the next release.

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
  • 14 replies
  • 2359 views
  • 10 likes
  • 5 in conversation