I am trying to do a simple SQL join and keep getting this error message. I'm can't figure what is wrong with my query that is causing the error. Where is there a missing period?
proc sql;
create table included_var as
select a.NAME, b.field_name
from varlist as a left join dictionary as b
on a.NAME = b.field_name
;
quit;
I get the following message in my log:
2003
2004
2005 proc sql;
2006 create table included_var as
2007 select a.NAME, b.field_name
2008 from varlist as a left join dictionary as b
--
78
ERROR 78-322: Expecting a '.'.
2009 on a.NAME = b.field_name
1 .
-
78
200
1 .
-
78
200
1 .
-
78
76
ERROR 78-322: Expecting a '.'.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 76-322: Syntax error, statement will be ignored.
2010 ;
2011 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
I think the word DICTIONARY is reserved by SQL, and you can't use it as the name of a SAS data set.
I think the word DICTIONARY is reserved by SQL, and you can't use it as the name of a SAS data set.
That was it! I changed the name of the dataset to DATA_DICTIONARY and it worked fine.
I haven't tried this, but I believe that WORK.DICTIONARY should work properly.
More precisely, the SQL interpreter expects e.g. "dictionary.tables" or "dictionary.columns" when encountering the token "dictionary". You could probably also get away with referring to your dictionary table as "work.dictionary".
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.