I am trying to replicate data cleaing steps, which are only available as SAS code and I am trying to understand, what the code actually does. This is part of code, which was used to clean TRACE data and was published by Jens **bleep**-Nielsen on SSRN. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2337908 I am struggling to understand the following part of the code, which are on p. 15-16 in the pdf. It basically is a merge operation and I would like to know, what the commands (in=qqq) and (in=qq) do. Are they some kind of internal ranking system, like Row_Number() in TSQL or what do they do. * Take out reversals into a dataset; data reversal temp_raw3; set temp_raw2; N=_N_; if asof_cd=’R’ then output reversal; else output temp_raw3; run; * Sorting the data so that it can be merged; proc sort data=reversal (drop = N) nodupkey; by trd_exctn_dt cusip_id trd_exctn_tm rptd_pr entrd_vol_qt rpt_side_cd cntra_mp_id trd_rpt_dt trd_rpt_tm MSG_SEQ_NB; run; proc sort data=temp_raw3; by trd_exctn_dt cusip_id trd_exctn_tm rptd_pr entrd_vol_qt rpt_side_cd cntra_mp_id; run; * Merges reversals back on and selects matching observations; data reversal2; merge temp_raw3 (in=qqq) reversal (in=qq) ; by trd_exctn_dt cusip_id trd_exctn_tm rptd_pr entrd_vol_qt rpt_side_cd cntra_mp_id; if qq=1; if qqq=1; * Reversal have to be on a later date 15 * (or else it would not be a reversal); * i.e. we do not delete potential as_of trades * from a later date that may match; if trd_exctn_dt < trd_rpt_dt; run; * Selects only 1 matching reversal (and keeps the rest); proc sort data=reversal2 nodupkey; by trd_exctn_dt bond_sym_id trd_exctn_tm rptd_pr entrd_vol_qt; run; proc sort data=reversal2; by N; run; proc sort data=temp_raw3; by N; run; * Deletes the macthing reversals; data temp_raw4; merge reversal2 (in=qq) temp_raw3; by N; if qq=0; run; * Ends the filter for PRE-change data; I hope this is pretty easy to solve for anyone who has a certain knowledge of SAS and sorry if this might be off-topic. Thanks a lot.
... View more