使用SAS从TAQ下载数据

使用SAS从TAQ下载数据,sas,wrds,Sas,Wrds,我正在尝试使用SAS在WRDS上下载整个TAQ数据库。以下是WRDS技术支持人员提供的SAS代码: %let wrds=wrds.wharton.upenn.edu 4016; options comamid=TCP remote=WRDS; signon username=_prompt_; %macro taq_daily_dataset_list(type=ctm,begyyyymmdd=20100101,endyyyymmdd=20111231) / des="Autogenerate

我正在尝试使用SAS在WRDS上下载整个TAQ数据库。以下是WRDS技术支持人员提供的SAS代码:

%let wrds=wrds.wharton.upenn.edu 4016;
options comamid=TCP remote=WRDS;
signon username=_prompt_;

%macro taq_daily_dataset_list(type=ctm,begyyyymmdd=20100101,endyyyymmdd=20111231) / des="Autogenerated list of needed Daily TAQ datasets";
    %let type=%lowcase(&type);
    /* Get SAS date values for date range endpoints */
    %let begdate = %sysfunc(inputn(&begyyyymmdd,yymmdd8.));
    %let enddate = %sysfunc(inputn(&endyyyymmdd,yymmdd8.));
        %do d=&begdate %to &enddate /** For each date in the DATE range */;
            %let yyyymmdd=%sysfunc(putn(&d,yymmddn8.));
            /*If the corresponding dataset exists, add it to the list */
            %if %sysfunc(exist(taqmsec.&type._&yyyymmdd)) %then taqmsec.&type._&yyyymmdd;
        %end;
%mend;

* using this macro;
data my_output;
  set %taq_daily_dataset_list(type=ctm,begyyyymmdd=20100101,endyyyymmdd=20121231) open=defer;
run;
我试着在SAS中运行它,但它给了我一个erorr“没有默认的输入数据集(_LAST_IS_NULL)”。我不知道如何使用SAS,一点也不知道。我只想下载数据库


非常感谢有人能帮我离开这里。

您正在运行的代码是从您的计算机到远程服务器的SAS/CONNECT会话。连接后,我假设在服务器上定义了libname TAQMSEC。因此,我猜您需要“远程提交”代码(这将在服务器的工作库中创建SAS数据集
my_输出
)。然后,您可以使用
PROC DOWNLOAD
将其复制到本地计算机:

%let wrds=wrds.wharton.upenn.edu 4016;
options comamid=TCP remote=WRDS;
signon username=_prompt_;

RSUBMIT; /* Execute following on server after logging in */

%macro taq_daily_dataset_list(type=ctm,begyyyymmdd=20100101,endyyyymmdd=20111231) / des="Autogenerated list of needed Daily TAQ datasets";
    %let type=%lowcase(&type);
    /* Get SAS date values for date range endpoints */
    %let begdate = %sysfunc(inputn(&begyyyymmdd,yymmdd8.));
    %let enddate = %sysfunc(inputn(&endyyyymmdd,yymmdd8.));
        %do d=&begdate %to &enddate /** For each date in the DATE range */;
            %let yyyymmdd=%sysfunc(putn(&d,yymmddn8.));
            /*If the corresponding dataset exists, add it to the list */
            %if %sysfunc(exist(taqmsec.&type._&yyyymmdd)) %then taqmsec.&type._&yyyymmdd;
        %end;
%mend;

* using this macro;
data my_output;
  set %taq_daily_dataset_list(type=ctm,begyyyymmdd=20100101,endyyyymmdd=20121231) open=defer;
run;

/* Download result to your computer */
proc download data=my_output;
run;

ENDRSUBMIT; /* Signals end of processing on remote server */
出现在
RSUBMIT
ENDRSUBMIT
命令之间的任何编程语句都将在远程服务器上执行。请注意,宏是由远程SAS会话创建和执行的


请记住,在检索到所需数据后,使用
注销
命令断开与服务器的连接。

正在运行的代码是从计算机到远程服务器的SAS/CONNECT会话。连接后,我假设在服务器上定义了libname TAQMSEC。因此,我猜您需要“远程提交”代码(这将在服务器的工作库中创建SAS数据集
my_输出
)。然后,您可以使用
PROC DOWNLOAD
将其复制到本地计算机:

%let wrds=wrds.wharton.upenn.edu 4016;
options comamid=TCP remote=WRDS;
signon username=_prompt_;

RSUBMIT; /* Execute following on server after logging in */

%macro taq_daily_dataset_list(type=ctm,begyyyymmdd=20100101,endyyyymmdd=20111231) / des="Autogenerated list of needed Daily TAQ datasets";
    %let type=%lowcase(&type);
    /* Get SAS date values for date range endpoints */
    %let begdate = %sysfunc(inputn(&begyyyymmdd,yymmdd8.));
    %let enddate = %sysfunc(inputn(&endyyyymmdd,yymmdd8.));
        %do d=&begdate %to &enddate /** For each date in the DATE range */;
            %let yyyymmdd=%sysfunc(putn(&d,yymmddn8.));
            /*If the corresponding dataset exists, add it to the list */
            %if %sysfunc(exist(taqmsec.&type._&yyyymmdd)) %then taqmsec.&type._&yyyymmdd;
        %end;
%mend;

* using this macro;
data my_output;
  set %taq_daily_dataset_list(type=ctm,begyyyymmdd=20100101,endyyyymmdd=20121231) open=defer;
run;

/* Download result to your computer */
proc download data=my_output;
run;

ENDRSUBMIT; /* Signals end of processing on remote server */
出现在
RSUBMIT
ENDRSUBMIT
命令之间的任何编程语句都将在远程服务器上执行。请注意,宏是由远程SAS会话创建和执行的


请记住,在检索到所需数据后,请使用
注销
命令断开与服务器的连接。

我不会说SAS,因此我无法对您的代码发表评论,但我不认为“taqmsec”是主文件之一。合并交易数据保存在taq.CT_yyyyymmdd格式的文件中,合并报价文件为taq.CQ_YYYYMMDD。第一个可用的日期是19930104

当我拥有一个帐户时,我编写了一些Python脚本来自动化从WRDS批量下载数据的过程:

尝试自动设置SSH密钥的脚本未经测试(如果您想帮助我测试/修复它们,请给我一个说明),但内核已经过良好测试。假设已设置帐户和基于密钥的身份验证,则可以运行:

import pywrds

# Download the TAQ Consolidated Trades (TAQ_CT) file for 1993-06-12.
# y = [num_files, num_rows, paramiko_ssh, paramiko_sftp, time_elapsed]

y = pywrds.get_wrds('taq.ct', 1993, 06, 12) 

# Loop over all available dates to download in bulk.
# The script is moderately smart about picking up 
# unfinished loops where they left off.
# y = [num_files, time_elapsed]

y = pywrds.wrds_loop('taq.ct')

# Find out what the darn names of the available TAQ files are.
# y = [file_list, paramiko_ssh, paramiko_sftp]

y = pywrds.find_wrds('taq')
1993年,每个文件的起始容量为几十MB,对于taq.ct,每个文件的容量增加到~1 GB,对于taq.cq,每个文件的容量增加到>5GB。标准WRDS帐户将您的存储空间限制为1GB,因此尝试查询所有文件(例如taq.cq_20050401)将在您的目录中放置一个截断的文件
pywrds.get_wrds
将这些大查询和循环分解到较小的文件上,然后在下载完所有文件后重新组合它们

警告:下载这些文件后,wrds_loop还会从服务器上的目录中删除这些文件。它还运行
rm wrds\u export*
,因为它上载的所有SAS文件都以“wrds\u export”开头。确保你没有任何其他遵循相同模式的东西

同样的命令也适用于Compustat(comp.fundq、comp.g_fundq等)、CRSP(CRSP.msf、CRSP.dsf等)、OptionMetrics(optionm.optionm_opprcd1996、optionm.opprcd1997等)、IBES、TFN等

# Also works with other WRDS datasets.
# The day, month, and year arguments are optional.

# Get the OptionMetrics pricing file for March 1993
y = pywrds.get_wrds('optionm.opprcd', 1993, 3)

# Get the Compustat Fundamentals Quarterly file for 1997
y = pywrds.get_wrds('comp.fundq', 1997)

# Get the CRSP Monthly Stock File for all available years
y = pywrds.get_wrds('crsp.msf')

我不会说SAS,所以我不能对你的代码发表评论,但我不认为“taqmsec”是主要文件之一。合并交易数据保存在taq.CT_yyyyymmdd格式的文件中,合并报价文件为taq.CQ_YYYYMMDD。第一个可用的日期是19930104

当我拥有一个帐户时,我编写了一些Python脚本来自动化从WRDS批量下载数据的过程:

尝试自动设置SSH密钥的脚本未经测试(如果您想帮助我测试/修复它们,请给我一个说明),但内核已经过良好测试。假设已设置帐户和基于密钥的身份验证,则可以运行:

import pywrds

# Download the TAQ Consolidated Trades (TAQ_CT) file for 1993-06-12.
# y = [num_files, num_rows, paramiko_ssh, paramiko_sftp, time_elapsed]

y = pywrds.get_wrds('taq.ct', 1993, 06, 12) 

# Loop over all available dates to download in bulk.
# The script is moderately smart about picking up 
# unfinished loops where they left off.
# y = [num_files, time_elapsed]

y = pywrds.wrds_loop('taq.ct')

# Find out what the darn names of the available TAQ files are.
# y = [file_list, paramiko_ssh, paramiko_sftp]

y = pywrds.find_wrds('taq')
1993年,每个文件的起始容量为几十MB,对于taq.ct,每个文件的容量增加到~1 GB,对于taq.cq,每个文件的容量增加到>5GB。标准WRDS帐户将您的存储空间限制为1GB,因此尝试查询所有文件(例如taq.cq_20050401)将在您的目录中放置一个截断的文件
pywrds.get_wrds
将这些大查询和循环分解到较小的文件上,然后在下载完所有文件后重新组合它们

警告:下载这些文件后,wrds_loop还会从服务器上的目录中删除这些文件。它还运行
rm wrds\u export*
,因为它上载的所有SAS文件都以“wrds\u export”开头。确保你没有任何其他遵循相同模式的东西

同样的命令也适用于Compustat(comp.fundq、comp.g_fundq等)、CRSP(CRSP.msf、CRSP.dsf等)、OptionMetrics(optionm.optionm_opprcd1996、optionm.opprcd1997等)、IBES、TFN等

# Also works with other WRDS datasets.
# The day, month, and year arguments are optional.

# Get the OptionMetrics pricing file for March 1993
y = pywrds.get_wrds('optionm.opprcd', 1993, 3)

# Get the Compustat Fundamentals Quarterly file for 1997
y = pywrds.get_wrds('comp.fundq', 1997)

# Get the CRSP Monthly Stock File for all available years
y = pywrds.get_wrds('crsp.msf')

该错误与您的代码不一致。唯一明显错误的是没有定义libname taqmsec,但这可能发生在tcp文件中。但是,您可能需要获取tcp连接脚本。不管怎样,这个错误都意味着你有一个类似于进程排序(或任何进程)的东西,没有数据=参数。这个错误与你的代码不一致。唯一明显错误的是没有定义libname taqmsec,但这可能发生在tcp文件中。但是,您可能需要获取tcp连接脚本。但是,无论哪种方式,该错误都意味着您有一个类似于过程排序(或任何过程)的东西,没有数据=参数。