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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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