Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query SAS from R over SSH [closed]

Tags:

ssh

r

sas

I would like to query a SAS database from R and return the data into R, and I have to connect to the SAS database through SSH. How do I get started?

like image 682
michaelcarniol Avatar asked Nov 13 '22 21:11

michaelcarniol


1 Answers

To do this using ssh you could try running a remote command that will 'pipe' the results (ie. send them to stdout) back to the ssh client. Have R capture these results directly, or pipe them to a file using the OS and then import them to R.

If the remote computer is running SAS this should be easier as you can just execute sas and tell it to print the results to standard output.

So your command would look something like this:

C:\Progra~1\ICW\bin\ssh.exe servername -l username -i c:\id_rsa " sas -sysin myquery.sas " > results.txt

The above calls sas on the remote system and tells it to run a sas program named myquery.sas. Make that query print the results to stdout which will then be returned to the client. The client saves all the results to results.txt which you can then import using R.

Sorry I don't know R so I can't help you with the R portions of the code. If someone else does feel free to edit/add to this.

like image 137
Robert Penridge Avatar answered Nov 15 '22 12:11

Robert Penridge