DATA Step, Macro, Functions and more

Error while joining

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

Error while joining

          options nocenter compress=yes nomlogic symbolgen;
2          options nofullstimer mprint;
3         
4          libname ayb "hasasaa/reporting/projects/adhoc_pm_sadiq/sasdata";
NOTE: Library AYB does not exist.
5          libname ayb_lu "hasasaa/reporting/projects/p_6018_AYB/sasdata";
NOTE: Library AYB_LU does not exist.
6         
7         
8          Proc sql;
9           Create table match_ayb as
10          Select a.*
11          ,b.*
12          From ayb_lu.lu_ayb as a
13          left join ayb.AYB-WELLNESS CNPS_Q1 2017 as b
                             _
                             22
                             76
ERROR 22-322: Syntax error, expecting one of the following: a name, (, AS, ON. 

 

Hello I keep getting this error, also it is saying my libaraires do not exist. If someone could help, that would be helpful!

 

Thank you


Accepted Solutions
Solution
‎05-23-2017 10:33 AM
Super User
Posts: 7,866

Re: Error while joining

hasasaa/reporting/projects/p_6018_AYB/sasdata

is a UNIX relative path name (does not start with a forward slash, and therefore not at the root directory), so SAS will start searching from the directory where the SAS process was started (usually a location in the SAS configuration tree), so you won't find the directory for the library.

Use the absolute path, starting at the root directory of the server; if the path is found in your home directory ("Files" in Enterprise Guide), use $HOME as the start.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
PROC Star
Posts: 768

Re: Error while joining

Seems to me that you have a space in

 

ayb.AYB-WELLNESS CNPS_Q1 2017 as b

which causes this problem

 

Occasional Contributor
Posts: 19

Re: Error while joining

I did take out the space but the same error keeps coming up

Occasional Contributor
Posts: 19

Error while joining

Hello

 

I keep getting this error while trying to join, and also my libaries are saying do not exist? I just wanted to see where the on, as was missing. I cant seem to figure it out thanks

 

 

 

NOTE: Library SASDATA does not exist.
5          libname sasdatap "hasasaa/reporting/projects/p_6018_AYB/sasdata";
NOTE: Library SASDATAP does not exist.
6         
7         
8          Proc sql;
9           Create table match_ayb as
10          Select a.*
11          ,b.*
12          From sasdatap.lu_ayb a
13          Left join sasdata.AYB-WELLNESSCNPS_Q12017 b
                                 _
                                 22
                                 76
ERROR 22-322: Syntax error, expecting one of the following: a name, (, AS, ON. 

Super User
Posts: 7,866

Re: Error while joining

AYB-WELLNESSCNPS_Q12017

is not a valid SAS name (only characters, digits and underlines). Replace the dash with an underline (as it should already have been, as you wouldn't be able to create such a dataset anyway).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎05-23-2017 10:33 AM
Super User
Posts: 7,866

Re: Error while joining

hasasaa/reporting/projects/p_6018_AYB/sasdata

is a UNIX relative path name (does not start with a forward slash, and therefore not at the root directory), so SAS will start searching from the directory where the SAS process was started (usually a location in the SAS configuration tree), so you won't find the directory for the library.

Use the absolute path, starting at the root directory of the server; if the path is found in your home directory ("Files" in Enterprise Guide), use $HOME as the start.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 11,343

Re: Error while joining

It also helps to post error messages with code from the log into a code box opened with the forum {i} icon as the main message windows reformat your text somewhat and the position of the _ in the error message helps diagnose the code.

Example with code box:

55   proc sql;
56      select *
57      from sashelp.c-lass;
                      -
                      22
                      76
ERROR 22-322: Syntax error, expecting one of the following: GROUP, HAVING, ORDER, WHERE.

the _ is under the dash showing where the exact error is.

 

But in the main window:

55 proc sql;

56 select *

57 from sashelp.c-lass;

-

22

76

ERROR 22-322: Syntax error, expecting one of the following: GROUP, HAVING, ORDER, WHERE.

 

The _ indicator is now in a much less helpful position.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 163 views
  • 0 likes
  • 4 in conversation