Hi, try the code below to see if you get what you want (repace the RED part with your real dataset name, the dataset you want to add obsevations on): %macro LMGenerate(mymktdata,yeartag); data &mymktdata.highliquidity; *blah blah; run; data &mymktdata.lowliquidity; *blah blah; run; *this is basically difference of above 2 datasets data _&mymktdata; update &mymktdata.lowliquidity(in = a) &mymktdata.highliquidity(in =b); by year; if a & b then do; netpremium=lowliquiditytotal-highliquiditytotal; output; end; run; %mend LMGenerate; %LMGenerate(yr2010mktdata,2010 ) %LMGenerate(yr2011mktdata,2011 ) *global data; data want; set your_global_dataset_name _:; run;
... View more