BookmarkSubscribeRSS Feed
curlygirl
Fluorite | Level 6
Hi,

I have problem running code listed below:

Proc sql;

Select

smlo.cislo_smlouvy
smlo.cislo_ramcove_smlouvy,
Skud.cislo_skodni_udalosti,
to_char(skud.datum_vzniku, ‘yyyy’) as vznik,
Scov.kod_scov

From dwh.bcdf_smlo_smlouvy silo
Inner join dwh.bcdf_skud_skodni_udalosti skud on skud.smlo_pk=smlo.smlo_pk
Inner join dwh.bcdd_pssu_podslozky_su puss on pssu.skud_pk=skud_pk
Inner join dwh.bcdd_scov_subcover scoop on scov.scov_pk=pssu.scov_ok

Where smlo.cislo_ramcove_smlouvy = (‘898306813’)

;quit

Each time I have problem with “smlo.cislo_ramcove_smlouvy”, it comes back with:

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

Do you see any issue in the code? Will be thankful for any help.
Thanks!
8 REPLIES 8
PaigeMiller
Diamond | Level 26

I don't see where smlo is an alias associated with a data set. You have data sets with aliases silo, skud, puss and scoop, but no smlo.

 

From now on, please show us the entire log for this code, instead of parts of the log disconnected from the code.

--
Paige Miller
curlygirl
Fluorite | Level 6
Thanks! That helped
Shmuel
Garnet | Level 18

Beyond @PaigeMiller's answer, you miss the comma after the first selected variable.

ballardw
Super User

When you have questions about messages such as errors or warnings please always copy the entire procedure or data step along with all notes, messages, warnings and errors from the LOG. Then open a text box on the forum using the </> icon at the top of the message window and paste all the text. This preserves formatting of text. Many errors, such as the one you show will have diagnostic characters that indicate exactly where SAS determines the particular error appears. The message windows here will reformat the text but the text box will preserve the location of the diagnostic characters.

 

Please see this example similar to yours.  Notice I include the entire procedure and it becomes pretty clear where the particular error occurs.

209  proc sql;
210     select a.sex
211            b.age
               -
               22
               76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, /, <, <=,
              <>, =, >, >=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE,
              LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

212     from sashelp.class
213          left join
214          sashelp.class as b
215          on a.name=b.name
216     ;
217  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds

The underscore under the B on line 211 is the issue because of the missing , between it and the first variable selected.

And after that is corrected we get

218  proc sql;
219     select a.sex,
220            b.age
221     from sashelp.class
222          left join
223          sashelp.class as b
224          on a.name=b.name
225     ;
ERROR: Unresolved reference to table/correlation name a.
ERROR: Unresolved reference to table/correlation name a.
226  quit;

because of the unassigned correlation for the table. Such as your code would likely get as @PaigeMiller points out.

 

curlygirl
Fluorite | Level 6

Thanks! Will keep it in mind.

 

I fixed the things everyone mentioned above and changed "to_chat" since its used only in SQL app, not in SAS Enterprise Guide. However, now I have problem with the Where section.

 

24         Proc sql;

25         Select

26         

27         smlo.cislo_smlouvy,

28         smlo.cislo_ramcove_smlouvy,

29         Skud.cislo_skodni_udalosti,

30         vznik =year(datepart(skud.datum_vzniku)),

31         Scov.kod_scov

32         

33         From dwh.bcdf_smlo_smlouvy smlo

34         Inner join dwh.bcdf_skud_skodni_udalosti skud on skud.smlo_pk=smlo.smlo_pk

35         Inner join dwh.bcdd_pssu_podslozky_su pssu on pssu.skud_pk=skud.skud_pk

36         Inner join dwh.bcdd_scov_subcover scov on scov.scov_pk=pssu.scov_ok

37         

38         Where smlo.cislo_ramcove_smlouvy = ’898306813’

                                              _

                                              22

                                              200

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,

              a missing value, (, *, +, -, ALL, ANY, BTRIM, CALCULATED, CASE, INPUT, PUT, SELECT, SOME, SUBSTRING, TRANSLATE,

              USER. 

 

ERROR 200-322: The symbol is not recognized and will be ignored.

 

39         

40         ;

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.

40       !  quit

 

The number in Where line refers to agreement number. Is there any solution to resolve the problem?

PaigeMiller
Diamond | Level 26

Pasting the log into your reply does not maintain the formatting of the log. We request that you follow these instructions: in the icon bar above where you type your reply, click on the </> and paste the log into the window that appears. This preserves the formatting of the log and makes it easier for us to figure out what is going on. Thank you.

--
Paige Miller
Tom
Super User Tom
Super User

If you use a fixed font for the text you can see that SAS is complaining about that strange character after the equal sign that looks more like a superscript version of a comma than an actual quote character.  Most likely you copied that code from some word processor software that replaced the quotes with "stupid" quotes.

38         Where smlo.cislo_ramcove_smlouvy = ’898306813’
                                              _
                                              22
                                              200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
              a missing value, (, *, +, -, ALL, ANY, BTRIM, CALCULATED, CASE, INPUT, PUT, SELECT, SOME, SUBSTRING, TRANSLATE,
              USER. 

ERROR 200-322: The symbol is not recognized and will be ignored.

Replace those strange characters around the digit string with real quote characters.

Kurt_Bremser
Super User

Always use this button to post logs (or textual data, or non-SAS code):

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

This will keep all the original formatting, and make it much easier to identify the problem.

You have a "curly" (UTF) single quote there.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 8 replies
  • 3122 views
  • 4 likes
  • 6 in conversation