Skip to content

Instantly share code, notes, and snippets.

View mgao6767's full-sized avatar
😀

Adrian Gao mgao6767

😀
View GitHub Profile
options mprint;
%macro lowcase(dsn);
%let dsid=%sysfunc(open(&dsn));
%let num=%sysfunc(attrn(&dsid,nvars));
%put #
data &dsn;
set &dsn(rename=(
%do i = 1 %to #
/*function of varname returns the name of a SAS data set variable*/
%let var&i=%sysfunc(varname(&dsid,&i));
data tmp;
merge anncomp(in=ina) some_ceo_year_events(in=inb);
by gvkey year execid;
flag = inb;
if ina;
run;
@mgao6767
mgao6767 / ffind.ado
Created February 25, 2018 18:16
STATA program to create Fama-French 48 Industries from SIC
/****************************************
* ffind.ado
* Creates variable containing Fama-French
* industry classification.
*
* Author: Judson Caskey, UCLA
* December 9, 2007
*
* Revised by Malcolm Wardlaw, Uiversity of Texas at Dallas (November 1, 2011)
****************************************/
@mgao6767
mgao6767 / wp-config.php
Last active October 7, 2018 09:14
To resolve infinite login loop
<?php
/* To resolve the login loop issue */
define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');
/* end */
/* That's all, stop editing! Happy blogging. */
@mgao6767
mgao6767 / bitnami.conf
Last active October 12, 2018 01:04
bitnami.conf for alice.com
<VirtualHost *:80>
ServerName alice.com
DocumentRoot "/opt/bitnami/apache2/htdocs"
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
@mgao6767
mgao6767 / Install required packages and download AlgoVPN.sh
Last active January 9, 2019 05:29
Install required packages and download AlgoVPN
sudo apt-get update && sudo apt-get install \
git \
build-essential \
libssl-dev \
libffi-dev \
python-dev \
python-pip \
python-setuptools \
python-virtualenv -y
@mgao6767
mgao6767 / Install remaining dependencies.sh
Last active January 9, 2019 05:30
AlgoVPN: Install remaining dependencies
python -m virtualenv --python=`which python2` env &&
source env/bin/activate &&
python -m pip install -U pip virtualenv &&
python -m pip install -r requirements.txt
@mgao6767
mgao6767 / Tobin's Q and Altman Z Score for Compustat Companies.sas
Created January 22, 2019 14:53
Tobin's Q and Altman Z Score for Compustat Companies
/* ********************************************************************************* */
/* ************** W R D S R E S E A R C H A P P L I C A T I O N S ************** */
/* ********************************************************************************* */
/* Summary : Tobin's Q and Altman Z Score for Compustat Companies */
/* Date : August 24, 2011 */
/* Author : Rabih Moussawi */
/* Variables : - Computes proxies for Tobin's Q and Altman Z using Financial Ratios */
/* - Proxy for Age of company using number of years with available data */
/* - Adds delisting reason and delisting date information */
/* ********************************************************************************* */
@mgao6767
mgao6767 / winsorize.sas
Last active January 25, 2019 10:42 — forked from JoostImpink/winsorize.sas
winsorize macro
/*****************************************
Author unknown - that is a pity because this macro is the best since sliced bread!
Trim or winsorize macro
* byvar = none for no byvar;
* type = delete/winsor (delete will trim, winsor will winsorize;
*dsetin = dataset to winsorize/trim;
*dsetout = dataset to output with winsorized/trimmed values;
*byvar = subsetting variables to winsorize/trim on;
@mgao6767
mgao6767 / Calculate Institutional Ownership, Concentration, and Breadth Ratios.sas
Created January 24, 2019 05:19
Calculate Institutional Ownership, Concentration, and Breadth Ratios
/* ********************************************************************************* */
/* ************** W R D S R E S E A R C H A P P L I C A T I O N S ************** */
/* ********************************************************************************* */
/* Summary : Calculate Institutional Ownership, Concentration, and Breadth Ratios */
/* Date : May 18, 2009 */
/* Author : Luis Palacios, Rabih Moussawi, and Denys Glushkov */
/* Variables : - INPUT : Thomson-Reuters 13F Data (TR-13F) S34TYPE3 Holdings data */
/* S34TYPE1 data for FDATE and RDATE variables */
/* - OUTPUT: IO_TimeSeries dataset with IO variables for common stocks */
/* ********************************************************************************* */