BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

Hello

There is a code that run in sql server 

select  *
FROM Application
WITH (NOLOCK)

I want to run this code in SAS (There is a library called enginal where can see the tables in sql server)

What is the way to run it in sas?

proc sql;
create table Application as
select *
FROM enginal.Application
WITH (NOLOCK)
;
quit;
 

Error

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

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

Accepted Solutions
Patrick
Opal | Level 21

WITH NOLOCK() is not SAS SQL syntax flavour. One option is to use explicit SQL passthrough as then you can just have SAS to send the SQL Server syntax as-is to the DB for execution.

proc sql;
  connect using enginal;
  select * from connection to enginal
    ( select * FROM Application WITH (NOLOCK) )
    ;
quit;

View solution in original post

7 REPLIES 7
yabwon
Onyx | Level 15

Did you try:

proc sql;
create table Application as
select *
FROM enginal.Application
;
quit;

?

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Ronein
Meteorite | Level 14

Sure but you didnt add "With No LOCK" and didnt add equivalent SAS code to  "WITH NO LOCK"

yabwon
Onyx | Level 15

1) I asked did you execute "plain"?

proc sql;
create table Application as
select *
FROM enginal.Application
;
quit;

You didn't answer.

 

2) It's hard to add something that does no exist...

 

The "with NOLOCK" is SQL Server specific..

a) https://www.sqlshack.com/understanding-impact-clr-strict-security-configuration-setting-sql-server-2...

b) https://stackoverflow.com/questions/686724/what-is-with-nolock-in-sql-server

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Ronein
Meteorite | Level 14
I have executed your code.it is the regular query. I think the code provided here answer the question
proc sql;
create table Application as
select *
FROM enginal.Application(read_lock_type=nolock)
;
quit;
Patrick
Opal | Level 21

WITH NOLOCK() is not SAS SQL syntax flavour. One option is to use explicit SQL passthrough as then you can just have SAS to send the SQL Server syntax as-is to the DB for execution.

proc sql;
  connect using enginal;
  select * from connection to enginal
    ( select * FROM Application WITH (NOLOCK) )
    ;
quit;
Ronein
Meteorite | Level 14

You solution is perfect.

I have another question-

Is there a SAS code that  do same like "With No Loc(sql server)?

 

Patrick
Opal | Level 21

@Ronein wrote:

You solution is perfect.

I have another question-

Is there a SAS code that  do same like "With No Loc(sql server)?

 


I normally look into the SAS docu for the access engine to answer such questions. If using the docu you would find READ_LOCK_TYPE= Data Set Option

READ_LOCK_TYPE=ROW | PAGE | TABLE | NOLOCK | VIEW

proc sql;
  create table Application as
  select *
  FROM enginal.Application(read_lock_type=nolock)
  ;
quit;

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1745 views
  • 3 likes
  • 3 in conversation