Use SAS Macros on WRDS¶
The Wharton Research Data Services (WRDS) provides quite a handful of SAS macros that can be used directly. This article explains how to use those handy macros on WRDS when you use remote submission to run your code on the WRDS cloud. Lastly, it explains how to load and use third-party SAS macros from a URL.
Before everything, just make sure that this
autoexec.sas is located in the home folder on your WRDS cloud.
This code runs automatically when you've connected to the WRDS cloud. The first line assigns the default library references for you to use, e.g.
comp for Compustat. The second line makes available the macros. A list of these handy macros is available at the WRDS documentation.
If you don't have this SAS code in the home folder, simply create one there or you can choose to include these two lines of code in your remotely submitted code.
Let's say we want to winsorize a dataset by using the macro provided by WRDS (full code). Below is an example of winsorizing Total Assets
AT of Compustat sample by fiscal year from 1980 to 2018.
Invoking the macro is as simple as a single line (line 18 above):
However, one thing to note about this particular winsorization macro by WRDS is that a variable named
a is used in line 57 and 59. So if the
INSET has a variable named
a as well, there’ll be possible data integrity issue. Hence, I prefer to use another version described in my other post Winsorization in SAS.
Load SAS macros from URL¶
I tend to collect and store all useful macros on my personal server, hence I don't need to worry about a loss of or changes to the macros. To use these macros, simply include them before invoking.
Then, I can simply call
winsor as below.