This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH windows AS ( | |
SELECT permno, namedt, nameenddt, | |
CASE WHEN lag(nameenddt) OVER w + interval '3 days' > namedt THEN 0 | |
ELSE 1 END AS new_period | |
FROM crsp.stocknames | |
WINDOW w AS (PARTITION BY permno ORDER BY namedt, nameenddt)), | |
window_nums AS ( | |
SELECT *, sum(new_period) OVER w AS listing_period |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
sics AS ( | |
SELECT DISTINCT gvkey, sic::integer | |
FROM comp.company), | |
obs AS ( | |
SELECT gvkey, datadate, fyear, COALESCE(sich, sic) AS sic, fic | |
FROM comp.funda | |
INNER JOIN sics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2 | |
sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE AGGREGATE array_aggcat (anyarray) | |
( sfunc = array_cat, | |
stype = anyarray, | |
initcond = '{}' | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh -C hackintosh '/opt/local/bin/port installed | grep texlive' | \ | |
perl -ne '$_ =~ s/^\s+([^\s]*).*?$/\1/; print "$_";' | \ | |
xargs sudo port install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sys.setenv(PGHOST="iangow.me", PGDATABASE="crsp") | |
devtools::source_url(paste0("https://raw.githubusercontent.com/iangow/", | |
"acct_data/master/code/getEventReturnsDaily.R")) | |
sql <- " | |
SELECT DISTINCT permno, comnam, gvkey, rdq | |
FROM crsp.stocknames AS a | |
INNER JOIN crsp.ccmxpf_linktable AS b | |
ON a.permno=b.lpermno | |
INNER JOIN comp.fundq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE AGGREGATE public.median(double precision) ( | |
SFUNC=public.plr_array_accum, | |
STYPE=float8[], | |
FINALFUNC=r_median | |
); | |
CREATE OR REPLACE FUNCTION public.r_median(double precision[]) | |
RETURNS double precision AS | |
$BODY$ | |
median(arg1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Get do file | |
@lines = <STDIN>; | |
# Get files used | |
foreach my $line (@lines) { | |
if ($line =~ /(?:use|(?:merge|joinby).*using)\s+"?(\w+)/) { | |
push @stata_files, $1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
print(os.environ['PGHOST']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkgs <- list.files("/Library/Frameworks/R.framework/Versions/3.6/Resources/library") | |
install.packages(pkgs) |
OlderNewer