BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
andrea_magatti
Obsidian | Level 7

Hi all,

a simple question:

while trying to run a proc fedsql inside a call execute loop i'm getting a strange error:

data _null_;
 a= "MD";
 set GNC.GNC_CAUSES_NO_EDGE_BACK(obs=1);
 call execute('proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class ='||a||'; quit;');
run;

BTW: the dataset live in a cas library

 

I'm getting this error:

NOTE: There were 1 observations read from the data set GNC.GNC_CAUSES_NO_EDGE_BACK.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

NOTE: CALL EXECUTE generated line.
1         + proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class =MD;
1         +                                                                                                                 quit;
ERROR: Column "MD" not found or cannot be accessed
ERROR: Azione interrotta a causa di errori.
ERROR: The FedSQL action was not successful.
NOTE: PROC FEDSQL has set option NOEXEC and will continue to prepare statements.

NOTE: PROCEDURE FEDSQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds

I've tested the same code using proc SQL, with no problem, but since the main table is huge i would like to use fedsql (much faster)

I'm on viya 3.5 executed from a local SAS session.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

PROC FEDSQL is probably treating "MD" as a variable reference and is expecting you to use single quotes for literals.  In PROC SQL you have to request this behavior but perhaps it is the default in PROC FEDSQL.

Tell the QUOTE() function to use single quotes.

quote(a,"'")

View solution in original post

5 REPLIES 5
ballardw
Super User

Pretty clear:

1         + proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class =MD;

No quotes around MD means SAS is using it as a variable not a literal value.

You want to generate

proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class ='MD';

  which might be easiest with

 

 call execute('proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL 
where id_class ='|| quote(a) ||'; quit;');

 

andrea_magatti
Obsidian | Level 7

Even stranger now:

after using your suggestion, I'm getting the same error:

NOTE: CALL EXECUTE generated line.
1         + proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class ="MD";
1         +                                                                                                                   quit;
ERROR: Column "MD" not found or cannot be accessed
ERROR: Azione interrotta a causa di errori.
ERROR: The FedSQL action was not successful.

It still says that it can't find the column, despite the quote function as:

data _null_;
 a= "MD";
 set GNC.GNC_CAUSES_NO_EDGE_BACK(obs=1);
 call execute('proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class ='||quote(a)||'; quit;');
run;

Many thanks for considering my request.

ballardw
Super User

Show a DIRECT call to fedsql that does work.

as in not generated by a data step, just the Proc fedsql submitted directly.

 

I am not familiar with all the stuff that gets involved with the connections. I am assuming the ID_class is a variable in the table GNC.REMI_VOL_2008_2021_FINAL. If not then I'm clueless at this point.

Tom
Super User Tom
Super User

PROC FEDSQL is probably treating "MD" as a variable reference and is expecting you to use single quotes for literals.  In PROC SQL you have to request this behavior but perhaps it is the default in PROC FEDSQL.

Tell the QUOTE() function to use single quotes.

quote(a,"'")
andrea_magatti
Obsidian | Level 7

Thanks!

Working!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 528 views
  • 0 likes
  • 3 in conversation