File Exchange

image thumbnail

okomarov/wrds

version 1.1.1.0 (751 KB) by Oleg Komarov
Matlab API to WRDS and SAS data sets

0 Downloads

Updated 15 Feb 2017

GitHub view license on GitHub

For a full description see https://github.com/okomarov/wrds
### Description
High level Matlab API that interacts with the Wharton Reasearch Data Services (WRDS) Unix server and its SAS data sets through SSH2.
### Description
First, run `wrds_install()` or add all relevant paths manually. You are ready to use `wrds()`.
### Requirements
* An account with WRDS of the type that admits SSH connections (PhD or above).
See WRDS's [account types](http://wrds-web.wharton.upenn.edu/wrds/support/Additional%20Support/Account%20Types.cfm) for details.
* [Java enabled](http://www.mathworks.co.uk/help/matlab/ref/usejava.html)

### Example

w = wrds('olegkoma','forgiveMeIfIDontTellYou');
w.cmd('echo "Hello World!"')

Download the [CRSPA/MSI dataset](http://wrds-web.wharton.upenn.edu/wrds/tools/variable.cfm?library_id=137&file_id=67079)

w.getDataset('CRSPA.MSI')

NOTE: check that your institution is subscribed to the CRSPA database through https://wrds-web.wharton.upenn.edu/wrds/mywrds/subscriptions.cfm, or query

w.getDatasetInfo('CRSPA.MSI')

if it comes back empty, you probably do not have access to that database.

Comments and Ratings (16)

Oleg Komarov

Hi Spy, have you read the description? The example is there. A nicely formatted description is available on github. All links are in the description.

Spy

Could you please provide an example for how to download TAQ data from WRDS using your code?

Mr Jensen

Hello
I hope you can help me :).
I have sent you the issue at github.

Oleg Komarov

Thanks for reporting on github, I took your issue from there.

Mr Jensen

Hello

I have an problem

Everything works fine until i try to run this command

// Command window //

>> getdatasetnames(wrds,libref)

Undefined function or variable 'passdlg'.

Error in wrds (line 50)
tmp = passdlg('ups');

What can be the problem?

Thanks!

Oleg Komarov

When I was developing it, I forgot that I manually created the tmp directory.
I updated the function to create the tmp directory at first run.

If you still find any problems or if you have suggestions or bug reports, you can also report them on https://github.com/okomarov/wrds/issues

Haoxuan Zou

Finally I figure out why it didn't work, I hadn't establish the '~/tmp' directory.

Haoxuan Zou

No, it told me:

Adding Ganymed-ssh2 to the java path by running
javaaddpath('/Users/zouhx11/Documents/MATLAB/jchen2/external/ssh2/ganymed-ssh2-build210/ganymed-ssh2-build210.jar')

Just added Ganymed-ssh2 to Matlab's dynamic java Classpath.
Retrieving SAS library names (libref).
Request submitted to WRDS servers.

w =

wrds with properties:

isVerbose: 1
isConnected: 1

Oleg Komarov

It seems as if you are not able to write to your ~/tmp/ directory.

If I SSH into WRDS, cd into tmp and ls -ld, I get:

wrds(~/tmp)% ls -ld
drwx------ ...

Also, when you login with w = wrds(...), does it retrieve the library names without errors?

Haoxuan Zou

Haoxuan Zou

My account type is: faculty, No Expiration Date
Sorry to bother you again and again

Oleg Komarov

What type of account do you have?

You can check on https://wrds-web.wharton.upenn.edu/wrds/mywrds/

Haoxuan Zou

When I ran:
w.getDatasetInfo('CRSPA.MSI')

Matlab told me:

etrieving dataset info for 'CRSPA.MSI'.
Request submitted to WRDS servers.

ans =

ERROR: Invalid file, /home/ubc/jchen/tmp/cmd.sas.

Oleg Komarov

Please check if your institution is subscribed to the yearly update of the CRSP via https://wrds-web.wharton.upenn.edu/wrds/mywrds/subscriptions.cfm?

Oleg Komarov

Hi, if you call w.getDatasetInfo('CRSPA.MSI'), do you get a line that reads:

"Access Permission rw-r-----"

Haoxuan Zou

I run your program on macbook it tells me:
Error using ssh2_main (line 169)

Error Transferring File
SEE JAVA ERROR BELOW

Java exception occurred:
java.io.IOException: Error during SCP transfer.
at ch.ethz.ssh2.SCPClient.get(SCPClient.java:703)
at ch.ethz.ssh2.SCPClient.get(SCPClient.java:596)
Caused by: java.io.IOException: Remote SCP error: scp: /home/ubc/jchen/tmp/fa7a29321_b8d7_4729_99c4_10428fcfc6d7.zip:
No such file or directory
at ch.ethz.ssh2.SCPClient.receiveFiles(SCPClient.java:325)
at ch.ethz.ssh2.SCPClient.get(SCPClient.java:699)
... 1 more

Error in ssh2 (line 84)
ssh2_struct = ssh2_main(ssh2_struct);

Error in scp (line 19)
ssh2_struct = ssh2(ssh2_struct);

Error in scp_get (line 50)
ssh2_struct = scp(ssh2_struct);

Error in wrds/SCPget (line 106)
obj.SSH2conn = scp_get(obj.SSH2conn, [rfname, rext], lpath, rpath);

Error in wrds/sas2csv (line 59)
wrds.SCPget(tmpzip, outfile);

Error in test (line 2)
w.sas2csv('CRSPA.MSI')

Can you tell me why this error occur?

Updates

1.1.1.0

edited description

1.1.0.0

Updated description

1.1.0.0

Changed logos.png

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Acknowledgements

Inspired by: SSH/SFTP/SCP For Matlab (v2)

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor