Nov 14, 2019
Most junior research students did not have any experience with data manipulation and analysis with SAS and the Wharton Research Data Services (WRDS), which motivates me about this tutorial series.
This post explains how to use those handy macros on WRDS when you use remote submission, following the previous one on how to encode your WRDS password and use remote submission to run your code on the WRDS cloud.
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:
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.
Use macros from a third party
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.