BookmarkSubscribeRSS Feed
rubence
Calcite | Level 5

Hi,

 

I have the following ODBC connection:

 

 

LIBNAME IFRS17_H ODBC DATAsrc=IFRS17_HIVE SCHEMA=ifrs17catalog USER="rubence" PASSWORD="XXXXXXXXXXX";

 

When I try to use a WHERE clause, 

data KFS;
set IFRS17_H.key_figures;
where key_figures.pyear='2024';
run;


SAS shows the following message:

rubence_0-1715157292434.png

 

 

but if I do not use a WHERE clause, I have no problems and the var names in the new table follows the structure: TABLE_NAME.VAR_NAME.

 

My questions are:

a) How can I avoid to download the full table?

b) Is It possible to use only the VAR_NAME and not TABLE_NAME.VAR_NAME?

 

Many thanks for your great help.

 

5 REPLIES 5
Patrick
Opal | Level 21

SAS data step syntax doesn't require (and doesn't support) two level names for variables. 

data KFS;
set IFRS17_H.key_figures;
where pyear='2024';
run;

In your syntax you expect variable pyear to be of type character. Should this not be the case (=it's numeric) then get rid of the quotes. ...and should this still not return the expected result then try year(pyear)=2024 

ballardw
Super User

A hint on how to read SAS error messages.

When you get a section of code underlined, as in this example, SAS is telling you where it found a problem. Sometimes the actual problem may be a missing semicolon on a previous line making the current line incorrect but that usually shows the underline at the start of the offending line(s).

 

So this message relates to the entire key_figures.pyear.  A very little research of code referencing variables will show that generally there is no two level name used in the data step. When it does occur it relates to specific types of uses such as First. Last. (used with BY group variables), hash keys and iterators and a few other elements of the Component Objects related to logging and Java.

 


@rubence wrote:

Hi,

 

I have the following ODBC connection:

 

 

LIBNAME IFRS17_H ODBC DATAsrc=IFRS17_HIVE SCHEMA=ifrs17catalog USER="rubence" PASSWORD="XXXXXXXXXXX";

 

When I try to use a WHERE clause, 

data KFS;
set IFRS17_H.key_figures;
where key_figures.pyear='2024';
run;


SAS shows the following message:

rubence_0-1715157292434.png

 

 

but if I do not use a WHERE clause, I have no problems and the var names in the new table follows the structure: TABLE_NAME.VAR_NAME.

 

My questions are:

a) How can I avoid to download the full table?

b) Is It possible to use only the VAR_NAME and not TABLE_NAME.VAR_NAME?

 

Many thanks for your great help.

 


 

Tom
Super User Tom
Super User

If you have the VALIDVARNAME option set to ANY then you can reference a non-standard variable name by using a NAME LITERAL.  They work similar to DATE LITERALS.  You add quotes around the name and append the letter N.

 

where "key_figures.pyear"n='2024';
rubence
Calcite | Level 5

I have tried your solution but SAS shows a new error:

 

rubence_0-1715245033895.png

 

Patrick
Opal | Level 21

@rubence Use a ONE LEVEL NAME. This is SAS data step and not SQL syntax.

data KFS;
  set IFRS17_H.key_figures;
  where key_figures.pyear='2024';
run;

 

...or if you're more comfortable with SQL then use SQL.

proc sql;
  create table work.KFS as
  select *
  from IFRS17_H.key_figures
  where key_figures.pyear='2024'
  ;
quit;

 The 2nd error message you get show that the SAS data step code gets converted into the DB SQL flavour that then gets sent to the DB for processing (so the where clause could subset the data on the DB side before transferring the data to SAS). ...but because in your code the data step syntax is wrong things ain't working.

 

If you add below options to your code then you'll get in the SAS log the info which SQL has been sent to the DB for in-database processing.

options  sastrace=(,,,d) sastraceloc=saslog nostsuffix;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 261 views
  • 0 likes
  • 4 in conversation