Skip to content

Instantly share code, notes, and snippets.

@joosti
Created December 2, 2014 01:19
Show Gist options
  • Select an option

  • Save joosti/c0c902cf30ba32751e8a to your computer and use it in GitHub Desktop.

Select an option

Save joosti/c0c902cf30ba32751e8a to your computer and use it in GitHub Desktop.
SAS Proc SQL Inner join
proc sql;
create table work.dsOut as
/* a.* means all records from work.dsIn
b.effdate means select effdate from misc.sdc
/
select a.*, b.effdate
from work.dsIn a
/* perform a left join */
left join misc.sdc b
/* require that gvkey is the same */
on a.gvkey = b.gvkey
/* and that the effdate is in the 365 day period before datadate */
and a.datadate - 365 <= b.effdate <= a.datadate;
quit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment