{"id":806,"date":"2017-04-23T00:25:29","date_gmt":"2017-04-23T04:25:29","guid":{"rendered":"http:\/\/www.kaikaichen.com\/?p=806"},"modified":"2017-04-25T15:58:00","modified_gmt":"2017-04-25T19:58:00","slug":"download-fr-y-9c-data-from-wrds","status":"publish","type":"post","link":"https:\/\/www.kaichen.work\/?p=806","title":{"rendered":"Download FR Y-9C data from WRDS"},"content":{"rendered":"<p>WRDS currently populates FR Y-9C data quarter by quarter in individual datasets, like BHCF200803, BHCF200806, BHCF200809 and so on. WRDS has not stacked those individual datasets to formulate a single time-series dataset like COMPUSTAT.<\/p>\n<p>There are two ways to overcome this:<\/p>\n<ol>\n<li>Use the web query on WRDS. The web query allows users to specify a date range and return a single time-series dataset.<\/li>\n<li>I wrote a SAS script which is equivalent to the web query but with more ease for future update. The code currently can accept a date range and download selected variables.<\/li>\n<\/ol>\n<pre class=\"lang:sas decode:true \"> %let wrds = wrds-cloud.wharton.upenn.edu 4016; \r\n options comamid=TCP remote=wrds;\r\n signon username = _prompt_;\r\n\r\nlibname local \"D:\\\";\r\n\r\nrsubmit;\r\n\r\n %let start = 2008Q1;                         \/*define start quarter      *\/ \r\n %let end = 2009Q4;                           \/*define end quarter        *\/ \r\n %let var = rssd9001, rssd9999, bhck2170;     \/*define selected variables *\/\r\n\r\n %macro date_loop(start,end);\r\n \/*converts the dates to SAS dates*\/\r\n %let start=%sysfunc(inputn(&amp;start,anydtdte9.));\r\n %let end=%sysfunc(inputn(&amp;end,anydtdte9.));\r\n \/*determines the number of quarters between the two dates*\/\r\n %let dif=%sysfunc(intck(quarter,&amp;start,&amp;end));\r\n %do i=0 %to &amp;dif;\r\n \/*advances the date i quarters from the start date and applies the yymmn. format*\/\r\n %let date=%sysfunc(putn(%sysfunc(intnx(quarter,&amp;start,&amp;i,e)),yymmn.));\r\n bank.bhcf&amp;date\r\n %end;\r\n %mend;\r\n \r\ndata tsbhc;\r\n  set %date_loop(&amp;start,&amp;end);\r\nrun;\r\n\r\nproc sql;\r\n  create table bhcdata as\r\n  select &amp;var from tsbhc;\r\nquit;\r\n\r\nproc download data=bhcdata out=local.bhcdata; run;\r\n\r\nendrsubmit;\r\nsignoff;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WRDS currently populates FR Y-9C data quarter by quarter in individual datasets, like BHCF200803, BHCF200806, BHCF200809 and so on. WRDS has not stacked those individual datasets to formulate a single time-series dataset like COMPUSTAT. There are two ways to overcome &hellip; <a href=\"https:\/\/www.kaichen.work\/?p=806\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,8],"tags":[],"_links":{"self":[{"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/posts\/806"}],"collection":[{"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=806"}],"version-history":[{"count":4,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/posts\/806\/revisions"}],"predecessor-version":[{"id":833,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/posts\/806\/revisions\/833"}],"wp:attachment":[{"href":"https:\/\/www.kaichen.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}