Merging datasets with 2 different time variables in SAS
Posted
by John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2010-03-15T09:56:43Z
Indexed on
2010/03/15
9:59 UTC
Read the original article
Hit count: 337
Hye Guys,
for those regularly browsing this site sorry for already another question (however I did solve my last question myself!)
I have another problem with merging datasets, it seems that accounting for time in datasets is a real pain in the ass. I succesfully managed to merge on months in my previous datasets, however it seems I have a final dataset which only has quarter as a time count variable. So where all my normal databases have month 1- xxx as an indicator of time, this database had quarter as an indicator of time.
I still want to add the variables of this last database, let's call it TVOL, into my WORK database.
Quick summary
QUARTER: Quarter 0 = JAN1996-MAR1996
Month: Month 0 = JAN1996
Example: TVOL
TVOL _ Ticker ____ Quarter
1500 _ AA ________ -1
52546 _ BB ________ 15
Example: WORK
BETA _ Ticker ____ Month
1.52 _ AA ________ 2
1.54__ BB _______ 3
Example: Merged:
BETA ______ TVOL __ Ticker ____ Month
1.52 _______ 500 ___ AA _______ 2
I now want to merge this 2 tables using following relationship
if the month is in quarter 1, the data of quarter 0 has to be used, so if i have an observation i nWORK with date 2FEB1996 the TVOL of quarter -1 has to be put behind this observation.
Something like IF month = quarter i use data quarter i-1.
Also, as TVOL is measured quarterly and I have to put in monthly I have to take the average, so (TVOL/3) should be added as a variable.
Thanks!
© Stack Overflow or respective owner