Are you asking a question, posing a problem, or simply wanting someone to do the work for you? Have you made any attempt to program in SAS the task you describe in your post?
Your post mentions "score value must be equals to that ID variable" yet the desired output you share with the forum does not match this condition.
From what I see, it appears that you want to use some technique to group your data on the SAMP variable, capturing the "last" (or maybe first?) non-missing SCORE variable value, but only if contributed by an observation having an ID variable in length greater than 5 characters.
An additional SAS DATA step could be used against your data set "A", after first sorting the data, and using a RETAIN statement to save the SCORE value in another variable when the appropriate ID and SAMP variable conditions are met.