wrds

Using Python dict values from external file in WRDS CRSP query

喜夏-厌秋 提交于 2021-01-28 11:14:55
问题 I would like to read dictionary values (CRSP PERMNOS) from an external file (a Python dict) and use them in a function that will return rows from a particular table. The code below, adapted from the WRDS Python Support site, works well with the PERMNO values written inline. def main(): parm = {'permnos': ('22074', '20482', '10049', '19641', '18980')} data = db.raw_sql('SELECT date,permno,comnam,cusip FROM crsp.dseall WHERE permno in %(permnos)s', params=parm) data.to_csv(r'cusip-result-2.csv'

SAS data step view and data wrap in a macro for loop

流过昼夜 提交于 2019-12-31 05:28:07
问题 For a university research project I am retrieving data from WRDS via SAS and am relatively new to SAS. I am trying to retrieve data in a specific interval provided by WRDS which actually works very for me; the structure is as follows [1]Define some macro variable [2]Use data step view [3]Make manipulation on data [4]Export the data to csv In particular I am retrieving data for a stock for every single year. Instead of changing the variable all the time a macro that would allow me to provide

SAS: Data step view -> error: by variable not sorted properly

点点圈 提交于 2019-12-11 09:24:36
问题 I am using a macro to loop through files based on names and extract data which works fine for the majority of the cases, however from time to time I experience ERROR: BY variables are not properly sorted on data set CQ.CQM_20141113. where CQM_20141113 is the file I am extracting data from. In fact my macro loops through CQ.CQM_2014: and it works up until 20141113. Because of this single failure the file is then not created. I am using a data step view to "initialize" the data and then in a