Hi Kurt, The two datasets that I originally posted here were actually just very small output portions of what were already in naratings and compq at that point in my SAS program. Thus, both naratings and compq have many more variables and observations in them and, as I indicated before, I desire to move my monthly data in naratings to fit appropriately at the next quarter-end in compq as mentioned before (in the case of the dates not coinciding with quarter-ends). Since I did not have the date variable (date=mdy(month,1,year)); referenced by you, I created that variable in both of these datasets and then made a slight adjustment to your code: proc sql; create table shift as select a.*, b.* from naratings (where=(rating ne "")) a left join compq b on a.gvkey = b.gvkey and a.date le b.date group by b.gvkey, b.date having a.date = max(a.date) ; create table want as select a.*, b.* from compq a left join shift b on a.gvkey = b.gvkey and a.year = b.year and a.month = b.month ; quit; On the log file with the creation of the first table (shift), we have: WARNING: Variable gvkey already exists on file WORK.SHIFT. WARNING: Variable datadate already exists on file WORK.SHIFT. WARNING: Variable cusip already exists on file WORK.SHIFT. WARNING: Variable year already exists on file WORK.SHIFT. WARNING: Variable month already exists on file WORK.SHIFT. WARNING: Variable date already exists on file WORK.SHIFT. With the creation of the second file (want), there is similar output but with many more variables. A small portion of the beginning of it is provided: WARNING: Variable gvkey already exists on file WORK.WANT. WARNING: Variable datadate already exists on file WORK.WANT. WARNING: Variable cusip already exists on file WORK.WANT. WARNING: Variable year already exists on file WORK.WANT. WARNING: Variable month already exists on file WORK.WANT. WARNING: Variable date already exists on file WORK.WANT. WARNING: Variable fyearq already exists on file WORK.WANT. WARNING: Variable fqtr already exists on file WORK.WANT. WARNING: Variable fyr already exists on file WORK.WANT. Note that the time references of year and month are indicated above. Am I correct to assume at this point that everything lines up well on date, but not year and month? Thank you for your help! Joe
... View more