SAS Syntax Expecting a SELECT
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
add a comment |
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
add a comment |
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
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
syntax sas quotes proc-sql where-in
asked Nov 20 at 21:55
resonance1
325
325
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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%')) ;
add a comment |
Use find operator
AND column3 in (('...','...','...',.......)
or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/
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
add a comment |
Add a pair parentheses for column3 condition
like this
AND (column3 in (('...','...','...',.......)
or column3 like ('J%'))) /*This AND statement gives the errors*/
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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%')) ;
add a comment |
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%')) ;
add a comment |
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%')) ;
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%')) ;
edited Nov 20 at 22:35
answered Nov 20 at 22:25
Kiran
2,4073819
2,4073819
add a comment |
add a comment |
Use find operator
AND column3 in (('...','...','...',.......)
or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/
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
add a comment |
Use find operator
AND column3 in (('...','...','...',.......)
or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/
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
add a comment |
Use find operator
AND column3 in (('...','...','...',.......)
or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/
Use find operator
AND column3 in (('...','...','...',.......)
or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/
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
add a comment |
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
add a comment |
Add a pair parentheses for column3 condition
like this
AND (column3 in (('...','...','...',.......)
or column3 like ('J%'))) /*This AND statement gives the errors*/
add a comment |
Add a pair parentheses for column3 condition
like this
AND (column3 in (('...','...','...',.......)
or column3 like ('J%'))) /*This AND statement gives the errors*/
add a comment |
Add a pair parentheses for column3 condition
like this
AND (column3 in (('...','...','...',.......)
or column3 like ('J%'))) /*This AND statement gives the errors*/
Add a pair parentheses for column3 condition
like this
AND (column3 in (('...','...','...',.......)
or column3 like ('J%'))) /*This AND statement gives the errors*/
answered Nov 23 at 8:41
Shuying WEI
11
11
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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