I am looking to merge on two variables, rather than just one. I want to match on both and ID number and a Date.
Thanks
data Final; merge Gts_7 (in=in1) Merged5; by ID Date; if in1; run;
You have to sort your data first.
proc sort data=Merged5;
by ID Date;
run;
What problems are you having?
@NickA1 wrote:
ERROR: BY variables are not properly sorted on data set WORK.MERGED5.
in1=0 Date=. Govt_Yield=. GT=30 Cusip=915217WX7 Yield=. FIRST.GT=0 LAST.GT=0 FIRST.Date=0
LAST.Date=0 _ERROR_=1 _N_=42
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 6 observations read from the data set WORK.GTS_7.
NOTE: There were 38 observations read from the data set WORK.MERGED5.
WARNING: The data set WORK.FINAL may be incomplete. When this step was stopped there were 5
observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.04 seconds
Seems like the error message (which I have highlighted in red) is relatively clear.
You have to sort your data first.
proc sort data=Merged5;
by ID Date;
run;
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!
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.
Ready to level-up your skills? Choose your own adventure.