Skip to content

Instantly share code, notes, and snippets.

View whentostart's full-sized avatar

QinghuaFeng whentostart

  • OU
  • norman
View GitHub Profile
@whentostart
whentostart / comp_segment_industrial_segment_count.sas
Created March 3, 2025 15:19 — forked from joosti/comp_segment_industrial_segment_count.sas
Compustat Segment files, count industrial segments per firm-year
/* count industrial segments
starting dataset, work.a_start with variables gvkey, fyear, datadate from Funda
*/
data b_segm (keep = GVKEY datadate STYPE SID IAS CAPXS NAICS NAICSH NAICSS1 NAICSS2 NIS OPS SALES SICS1 SICS2 SNMS SOPTP1 INTSEG);
set segments.Wrds_segmerged;
/* prevent duplicates: use the data when first published (not later years)*/
if srcdate eq datadate;
/* select business/operating (or, industrial) segments */
if stype IN ("BUSSEG", "OPSEG");
@whentostart
whentostart / SAS_macro_if_then_else.sas
Created August 12, 2024 20:14 — forked from joosti/SAS_macro_if_then_else.sas
SAS macros conditional code
/*
macro that computes the Herfindahl index for each industry-year
indVar can be SIC or NAICS
dsin needs to have gvkey, fyear, SICH or NAICSH
sample use: %computeIndSales(dsin=work.start, dsout=work.indsales, indVar=NAICS);
*/
%macro computeIndSales(dsin=, dsout=, indVar=SIC);
/* code for SIC */
@whentostart
whentostart / earnings_management_models.sas
Created March 30, 2024 04:49 — forked from JoostImpink/earnings_management_models.sas
Estimate earnings management models
/*
Earnings management models
Author: Joost Impink, March 2016
Models estimated:
- Jones model, tac = a0 + a1 1/TAt-1 + a2chSales + a3PPE + a4ROA + error.
- variable names DA_Jones ABSDA_Jones
- Modified Jones model, as Jones model, but using chSales - chREC to compute fitted values.
@whentostart
whentostart / common financial ratios.sas
Created February 27, 2024 05:06 — forked from mgao6767/common financial ratios.sas
Computes a broad range of financial ratios at both firm and the industry level using Fama-French industry classification.
/* ********************************************************************************* */
/* ******************** W R D S R E S E A R C H M A C R O S ******************** */
/* ********************************************************************************* */
/* WRDS Macro: INDRATIOS */
/* Summary : Computes a broad range of financial ratios aggregated at */
/* the industry level using Fama-French industry classification */
/* Date : Apr, 2009 */
/* Modified : Nov, 2010 */
/* Author : Denys Glushkov, WRDS */
/* Parameters: */
/* ********************************************************************************* */
/* ************** 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 */
/* ********************************************************************************* */
@whentostart
whentostart / ccmxpf.md
Created May 24, 2023 15:02 — forked from iangow/ccmxpf.md
A brief look at CRSP-Compustat merges

More up-to-date material on this topic can be found here.


From WRDS:

The WRDS-created linking dataset (ccmxpf_linktable) has been deprecated. It will continue to be created for a transition period of 1 year. SAS programmers should use the Link History dataset (ccmxpf_lnkhist) from CRSP.

And from here: