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
# include library | |
library(gtTranslator) | |
# define gla | |
gla <- MakeGLA(types = list(xType), | |
constants = list(size = xType$size), | |
representation = list(count = integer, XXT = translator::matrix(ncol = size, nrow = size), XY = xType), | |
prototype = function(count = 0, XXT = zeros(size, size), XY = zeros(size)){}, | |
# Add item: get called for each tuple in independent processes | |
AddItem = function(x, y) { | |
count = count + 1L |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
filename MYFILE "C:\temp\myData.csv"; | |
data myData; | |
infile MYFILE dsd delimiter="," firstobs=2 LRECL=32767 missover; | |
input id var1 var2 var3; | |
run; |
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
proc import | |
OUT = work.myData DATAFILE= "C:\temp\myData.xlsx" | |
DBMS = xlsx REPLACE; | |
SHEET = "worksheet1"; | |
GETNAMES = YES; | |
run; |
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
%macro myExport(dset=, file=); | |
%let filename = "&file"; | |
PROC EXPORT DATA= &dset OUTFILE=&filename DBMS=CSV REPLACE; | |
RUN; | |
%mend; |
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
/* summary statistics for full sample */ | |
proc means data=work.myData n mean median stddev; | |
OUTPUT OUT=work.meansout n= mean= median= stddev= /autoname; | |
var var1 var2 var3; | |
run; | |
/* as above, but repeated by a group (requires sorting on that variable) */ | |
proc means data=work.myData n mean median stddev; | |
OUTPUT OUT=work.meansout n= mean= median= stddev= /autoname; | |
var var1 var2 var3; |
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
/* | |
compute standard deviation of ROA over last 5 most recent years (including current) | |
requires at least 3 years of data | |
dsin: dataset with gvkey, fyear, firmyear (gvkey || fyear) and roa | |
dsout: dataset generated: dsin with roa_stddev appended */ | |
%macro roaStdev(dsin=, dsout=); | |
proc sql; |
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
data dataOut; | |
set dataIn; | |
/* repeat for each firm */ | |
by gvkey; | |
/* remember totsale across observations */ | |
retain totsale; | |
/* set sum to zero for first obs for each firm */ | |
if first.gvkey then totsale = 0; | |
/* add sale to total, you may need to set sale to 0 if missing | |
e.g. if sale eq . then sale = 0; |
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
data dataOut; | |
set dataIn; | |
by gvkey fyear; | |
sale_lag1 = ifn(gvkey=lag(gvkey) and fyear=lag(fyear)+1, lag(sale), .); | |
sale_lag2 = ifn(gvkey=lag2(gvkey) and fyear=lag2(fyear)+2, lag2(sale), .); | |
run; |
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
/* Sort by firm, year and audit fee (highest first) */ | |
proc sort data=dataIn; by gvkey fyear descending auditfee; run; | |
/* Keep each first firm-year (keeps highest audit fee) */ | |
proc sort data=dataIn nodupkey dupout=dataDropped; by gkvey fyear;run; |
OlderNewer