SAS libname for Oracle

Below SAS-code shows how to make a libname for Oracle directly in SAS-code by providing information about the Oracle server, that you want to access.

libname <YOUR CHOICE> oracle user=<USERNAME> pw=<PASSWORD> Schema=<SCHEMA ON ORACLE>
path="(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <NAME/IP-ADRESSE OF ORACLE SERVER)(PORT = <PORT FOR ORACLE SERVER. DEFAULT ORACLE PORT IS 1539))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = <DATABASE ON ORACLE SERVER>))
)";

Scanning all SAS-programs on server

The commands below will scan all *.sas files and look for the text proc. It will of course be possible to use any other string instead of proc. This scenario can be used to scan all your SAS-programs for the usage of SAS-procedures. Be aware that you need to be administrator or run the command as administrator to have access to all folders.

Linux
It will scan from the root of a server and go recursively through all the subfolders it encounters. It will pipe the result of the scan to the file linuxsasproc.txt in the folder where you start the execution of the command – this can of course be changed if you want to.

grep --include=\*.sas -rinw '/' -e 'proc' > linuxsasproc.txt

NB! The –include has two – -.

Output in linuxsasproc.txt. The file is delimited by : (colon)
<Location of SAS-program containing the search string>:<Line number in the file where the search string is found>:<The line that includes the search string>

Example
/sas/sasprogram.sas:24:proc sql;

Addition
In Linux I found that the command find has a maxdepth-option. This option makes it possible to decide, how far down a folder hierarchy a search should be preformed.
For example -maxdepth 1 will not search subfolders. This means that the command below will only search for files (-type f) in all folders matching  the folders with wildcard ./sasjobs/runningtime_*/ – but not subfolders of these folders.

find ./sasjobs/runningtime_*/ -maxdepth 1 -type f > result.txt

Windows
It will scan through all subfolder from the location where you start the program. It will pipe the result of the scan to the file winsasproc.txt in the folder where you start the execution of the command – this can of course be changed if you want to.

findstr /s /i proc *.sas > winsasproc.txt

NB! Be aware, that the DOS-commando findstr has an ‘Out of Memory‘ flaw.
Therefore, it can be better to use PowerShell, if this is available for you. The PowerShell command can look something like the below

Get-ChildItem -Path <PATH TO SCAN>:\*.sas -Recurse | Select-String -Pattern 'PROC' | Out-File "<FILE TO CONTAIN OUTPUT>"

An example below

Get-ChildItem -Path C:\*.sas -Recurse | Select-String -Pattern 'PROC' | Out-File "C:\output\sasscanoutput.csv"

Output in winssasproc.txt. The file is delimited by : (colon)
<Location of SAS-program containing the search string>:<The line that includes the search string>

Example
Documents\sasprogram.sas:proc sql;

Using TNSPING to get info about Oracle server

The command TNSPING can be used to get information about an alias for an Oracle server. Below you can see a screenshot from the command being executed in the command prompt for Windows.

In the command prompt you write: tnsping <the alias of your Oracle server>

TNSPING will return the

HOST Showing you the name of the physical host of the Oracle server.
PORT Showing you the port of the Oracle server on the physical host.
1521 is the default port for an Oracle server.