BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JKCho
Pyrite | Level 9

Hello,

 

I merged two(monthly and daily) and made a merged daily one but the daily one is not like what I want...

I used a merge code as below.

 

data CRSP_new;
set CRSP1;
year = YEAR(date);
run;

proc sql;
create table crspcomp as
select a.* , b.*
from cstatcusip1 a
inner join CRSP_new b
on a.cusip8 = b.cusip and a.fyear= b.year;
quit;

and... it made this

 

 

2.PNG

 

What I rather wanted to have is no double dates on NamesDate row in chronological order and the same in I/B/E/S row too.

As seen below, IBES is a monthly data set and it has median values that need to be matched by CUSIP and date. 

My problem is... medians need to be changed when corresponding I/B/E/S dates change.

 

 

1.PNG

 

 

This seems kind of advanced than I usually deal with and cannot be done by the above code as this time needs chronological order + corresponding changes in median values. I referred to some related threads but failed to make it. and finally asking for your help again...

 

Please share some advice again 

 

I sincerely appreciate all of your help!!

 

Jerry

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Examples of the input data would be helpful. You have hidden A LOT by not listing variable names as a minimum and likely cutting out much of the result.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Examples from BOTH of your INPUT data sets are needed.

 

Pictures of data are very hard to write code against.

It also appears that you need to match something by an actual date value, not the YEAR.

View solution in original post

3 REPLIES 3
ballardw
Super User

Examples of the input data would be helpful. You have hidden A LOT by not listing variable names as a minimum and likely cutting out much of the result.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Examples from BOTH of your INPUT data sets are needed.

 

Pictures of data are very hard to write code against.

It also appears that you need to match something by an actual date value, not the YEAR.

JKCho
Pyrite | Level 9
Somehow I solved the issue and thank for your help I will attach data code instead of pics later!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1110 views
  • 1 like
  • 3 in conversation