BookmarkSubscribeRSS Feed
Pato485
Calcite | Level 5

how can i do this, but in sas eg (odbc engine) through implicit statements? 

 

proc sql;
connect to sqlsvr as mydb
(datasrc="SASDATA" user="sas" password="xxx");
select * from connection to mydb
(CREATE INDEX ZP on dashboard_novacik (ZP) ;
CREATE INDEX Fin on dashboard_novacik (Fin) ;
);

QUIT;

 

This code works in SAS Studio (sqlsvr engine).

 

Thanks

3 REPLIES 3
Patrick
Opal | Level 21

Both SAS EG and SAS Studio are clients that connect to a SAS Server where the code executes.

If you're connecting with both clients to the same environment with the same user then the same code will work using either client.

 

Not sure about SQL Server but with many databases a Create Index would fail if the index already exists - meaning you would need to either first drop the index or check for existence.

Something like:

Patrick_0-1694158938710.png

 

Ksharp
Super User
"select * from connection to mydb" is for create a table.
If you want execute other SQL statement,your code should look like this:

proc sql;
connect to sqlsvr as mydb
(datasrc="SASDATA" user="sas" password="xxx");

execute(
CREATE INDEX ZP on dashboard_novacik (ZP) ;
CREATE INDEX Fin on dashboard_novacik (Fin) ;
) by mydb;

QUIT;

I am not very sure,check it more at support.sas.com
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0tpd3yaqvep53n1g8wahav3hgco.htm
Kurt_Bremser
Super User

Create a LIBNAME to the SQL Server schema, then run

proc sql;
create index zp on sqllib.dashboard_novacik (zp);
create index fin on sqllib.dashboard.novacik (fin);
quit;

But I would not be surprised if this does not work and you are forced to use explicit pass-through.

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
  • 3 replies
  • 953 views
  • 3 likes
  • 4 in conversation