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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With