I believe Dean makes the comparison for the first time in Devil's Trap, when he tells Sam, "you and Dad are a lot more alike than I thought, you know that? You both can’t wait to sacrifice yourself for this thing. But you know what? I’m gonna be the one to bury you. You’re selfish, you know that? You don’t care about anything but revenge." Dean lashes out at Sam with his anger at John as well as his frustration with Sam. John will die before Dean can reach a point where he will be comfortable ranting like that to John's face.
Dean makes the comparison again three seasons later in Jump the Shark. "You two were practically the same person," he tells Sam. He clearly does not mean this in a positive way.
Dean in JtS acts as if he never thought of this comparison before, which I find irritating from a dramatic perspective (repetition gets old), but believable from a character perspective. People forget things, especially when they live highly stressful lives.
Sam, despite his anger at his father, doesn't seem to mind the comparison. Not only does he make it without prompting in Dead Man's Blood, put he chooses to take Dean's description of the two of them as "the same person" in Jump the Shark as a compliment.
Did John himself think that he and Sam were alike? Sam's quote above from Dead Man's Blood was prompted by John saying, "We're just different." I'm thinking John didn't see it that way.
A lot of people remember how the YED in John's body told Dean he was proud of him, but the context is less well-recalled: "I’m proud of you. You know, Sam and I, we can get pretty obsessed. But you – you watch out for this family. You always have." At the end of the same episode, actual John says that he thought he and Sam say "eye-to-eye" on killing Azazel, but never does John himself make the kind of casual comment about his similarities to Sam that the YED makes while in his body.
When John in In My Time of Dying does tell Dean he's proud of him, he does so on essentially the same grounds as the YED - this time describing specific examples of Dean looking out for his family and expressing remorse for his own poor parenting. Sam, however, is mentioned only as the recipient of Dean's care and responsibility. John does not compare Sam to either himself or Dean.
Another example of a character comparing Sam to his father is Bobby in Lazarus Rising. Bobby points out that in trying to go it alone Sam is being like John. This is clearly intended as a criticism, and Sam takes it as such. Sam isn't the only Winchester brother who Bobby compares to John. In Lucifer Rising, we see Bobby saying Dean was being like John, after saying Dean sounded like a "whiny brat". With Bobby, it doesn't seem so much that he thinks either Sam or Dean is particularly like John. I think, rather, that Bobby considers it very important to see himself as a father to them, and as a better parent than John. I think Bobby is also insecure about his role in Sam and Dean's lives - he didn't actually raise them, after all. Hence a tendency to fall back on criticizing them by comparing them to their father.