SAS Syntax Expecting a SELECT












0














I'm unsure how to correct the syntax inside of my proc sql in SAS. My code goes something like the following:



proc sql;
create table HI
as select [columns]
from [table]
where column1 not in ('..', '..', '..') /*This has no errors*/
AND column2 in ('...', '...', '...') /*This has no errors*/
AND column3 in (('...','...','...',.......)
or column3 like ('J%')) /*This AND statement gives the errors*/


The first error is that it is expecting a SELECT and has underlined the first '...' for the condition on column3. (Error 79-322)



The next error is at the end of the conditions on column 3 before the OR statement. It says that it is expecting one of the following: a quoted string, !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?,..... (Error 22-322)



Then there are two more errors that say the symbol is not recognized and another that the statement will be ignored. --but I figure these will correct if the others are corrected.



Any help is appreciated :)










share|improve this question



























    0














    I'm unsure how to correct the syntax inside of my proc sql in SAS. My code goes something like the following:



    proc sql;
    create table HI
    as select [columns]
    from [table]
    where column1 not in ('..', '..', '..') /*This has no errors*/
    AND column2 in ('...', '...', '...') /*This has no errors*/
    AND column3 in (('...','...','...',.......)
    or column3 like ('J%')) /*This AND statement gives the errors*/


    The first error is that it is expecting a SELECT and has underlined the first '...' for the condition on column3. (Error 79-322)



    The next error is at the end of the conditions on column 3 before the OR statement. It says that it is expecting one of the following: a quoted string, !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?,..... (Error 22-322)



    Then there are two more errors that say the symbol is not recognized and another that the statement will be ignored. --but I figure these will correct if the others are corrected.



    Any help is appreciated :)










    share|improve this question

























      0












      0








      0


      1





      I'm unsure how to correct the syntax inside of my proc sql in SAS. My code goes something like the following:



      proc sql;
      create table HI
      as select [columns]
      from [table]
      where column1 not in ('..', '..', '..') /*This has no errors*/
      AND column2 in ('...', '...', '...') /*This has no errors*/
      AND column3 in (('...','...','...',.......)
      or column3 like ('J%')) /*This AND statement gives the errors*/


      The first error is that it is expecting a SELECT and has underlined the first '...' for the condition on column3. (Error 79-322)



      The next error is at the end of the conditions on column 3 before the OR statement. It says that it is expecting one of the following: a quoted string, !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?,..... (Error 22-322)



      Then there are two more errors that say the symbol is not recognized and another that the statement will be ignored. --but I figure these will correct if the others are corrected.



      Any help is appreciated :)










      share|improve this question













      I'm unsure how to correct the syntax inside of my proc sql in SAS. My code goes something like the following:



      proc sql;
      create table HI
      as select [columns]
      from [table]
      where column1 not in ('..', '..', '..') /*This has no errors*/
      AND column2 in ('...', '...', '...') /*This has no errors*/
      AND column3 in (('...','...','...',.......)
      or column3 like ('J%')) /*This AND statement gives the errors*/


      The first error is that it is expecting a SELECT and has underlined the first '...' for the condition on column3. (Error 79-322)



      The next error is at the end of the conditions on column 3 before the OR statement. It says that it is expecting one of the following: a quoted string, !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?,..... (Error 22-322)



      Then there are two more errors that say the symbol is not recognized and another that the statement will be ignored. --but I figure these will correct if the others are corrected.



      Any help is appreciated :)







      syntax sas quotes proc-sql where-in






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 21:55









      resonance1

      325




      325
























          3 Answers
          3






          active

          oldest

          votes


















          2














          change last 2 lines as



           AND (column3 in ('...','...','...',.......)
          or column3 like ('J%'))

          /* example*/
          proc sql;
          create table HI
          as select *
          from sashelp.cars
          where make not in ('Acura', 'Audi') /*This has no errors*/
          AND Type in ('SEDAN', "Sports") /*This has no errors*/
          AND (Origin in ('Asia','Europe')
          or Origin like ('U%')) ;





          share|improve this answer































            0














            Use find operator



            AND column3 in (('...','...','...',.......)
            or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/





            share|improve this answer























            • like work in proc sql too
              – Kiran
              Nov 20 at 22:22










            • @Kiran, my apologies, yes it works ..somehow I was using the wrong syntax
              – Rhythm
              Nov 20 at 22:50



















            0














            Add a pair parentheses for column3 condition
            like this



            AND (column3 in (('...','...','...',.......)
            or column3 like ('J%'))) /*This AND statement gives the errors*/





            share|improve this answer





















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402181%2fsas-syntax-expecting-a-select%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              change last 2 lines as



               AND (column3 in ('...','...','...',.......)
              or column3 like ('J%'))

              /* example*/
              proc sql;
              create table HI
              as select *
              from sashelp.cars
              where make not in ('Acura', 'Audi') /*This has no errors*/
              AND Type in ('SEDAN', "Sports") /*This has no errors*/
              AND (Origin in ('Asia','Europe')
              or Origin like ('U%')) ;





              share|improve this answer




























                2














                change last 2 lines as



                 AND (column3 in ('...','...','...',.......)
                or column3 like ('J%'))

                /* example*/
                proc sql;
                create table HI
                as select *
                from sashelp.cars
                where make not in ('Acura', 'Audi') /*This has no errors*/
                AND Type in ('SEDAN', "Sports") /*This has no errors*/
                AND (Origin in ('Asia','Europe')
                or Origin like ('U%')) ;





                share|improve this answer


























                  2












                  2








                  2






                  change last 2 lines as



                   AND (column3 in ('...','...','...',.......)
                  or column3 like ('J%'))

                  /* example*/
                  proc sql;
                  create table HI
                  as select *
                  from sashelp.cars
                  where make not in ('Acura', 'Audi') /*This has no errors*/
                  AND Type in ('SEDAN', "Sports") /*This has no errors*/
                  AND (Origin in ('Asia','Europe')
                  or Origin like ('U%')) ;





                  share|improve this answer














                  change last 2 lines as



                   AND (column3 in ('...','...','...',.......)
                  or column3 like ('J%'))

                  /* example*/
                  proc sql;
                  create table HI
                  as select *
                  from sashelp.cars
                  where make not in ('Acura', 'Audi') /*This has no errors*/
                  AND Type in ('SEDAN', "Sports") /*This has no errors*/
                  AND (Origin in ('Asia','Europe')
                  or Origin like ('U%')) ;






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 20 at 22:35

























                  answered Nov 20 at 22:25









                  Kiran

                  2,4073819




                  2,4073819

























                      0














                      Use find operator



                      AND column3 in (('...','...','...',.......)
                      or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/





                      share|improve this answer























                      • like work in proc sql too
                        – Kiran
                        Nov 20 at 22:22










                      • @Kiran, my apologies, yes it works ..somehow I was using the wrong syntax
                        – Rhythm
                        Nov 20 at 22:50
















                      0














                      Use find operator



                      AND column3 in (('...','...','...',.......)
                      or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/





                      share|improve this answer























                      • like work in proc sql too
                        – Kiran
                        Nov 20 at 22:22










                      • @Kiran, my apologies, yes it works ..somehow I was using the wrong syntax
                        – Rhythm
                        Nov 20 at 22:50














                      0












                      0








                      0






                      Use find operator



                      AND column3 in (('...','...','...',.......)
                      or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/





                      share|improve this answer














                      Use find operator



                      AND column3 in (('...','...','...',.......)
                      or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 20 at 22:55

























                      answered Nov 20 at 22:05









                      Rhythm

                      2106




                      2106












                      • like work in proc sql too
                        – Kiran
                        Nov 20 at 22:22










                      • @Kiran, my apologies, yes it works ..somehow I was using the wrong syntax
                        – Rhythm
                        Nov 20 at 22:50


















                      • like work in proc sql too
                        – Kiran
                        Nov 20 at 22:22










                      • @Kiran, my apologies, yes it works ..somehow I was using the wrong syntax
                        – Rhythm
                        Nov 20 at 22:50
















                      like work in proc sql too
                      – Kiran
                      Nov 20 at 22:22




                      like work in proc sql too
                      – Kiran
                      Nov 20 at 22:22












                      @Kiran, my apologies, yes it works ..somehow I was using the wrong syntax
                      – Rhythm
                      Nov 20 at 22:50




                      @Kiran, my apologies, yes it works ..somehow I was using the wrong syntax
                      – Rhythm
                      Nov 20 at 22:50











                      0














                      Add a pair parentheses for column3 condition
                      like this



                      AND (column3 in (('...','...','...',.......)
                      or column3 like ('J%'))) /*This AND statement gives the errors*/





                      share|improve this answer


























                        0














                        Add a pair parentheses for column3 condition
                        like this



                        AND (column3 in (('...','...','...',.......)
                        or column3 like ('J%'))) /*This AND statement gives the errors*/





                        share|improve this answer
























                          0












                          0








                          0






                          Add a pair parentheses for column3 condition
                          like this



                          AND (column3 in (('...','...','...',.......)
                          or column3 like ('J%'))) /*This AND statement gives the errors*/





                          share|improve this answer












                          Add a pair parentheses for column3 condition
                          like this



                          AND (column3 in (('...','...','...',.......)
                          or column3 like ('J%'))) /*This AND statement gives the errors*/






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 23 at 8:41









                          Shuying WEI

                          11




                          11






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402181%2fsas-syntax-expecting-a-select%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              404 Error Contact Form 7 ajax form submitting

                              How to know if a Active Directory user can login interactively

                              TypeError: fit_transform() missing 1 required positional argument: 'X'