Both like and such as can be used to introduce examples. This is what's going on in these two sentences that you gave:
A friend like you is a treasure / A friend such as you is a treasure
I hate tests like these / I hate tests such as these
However, such as cannot be used to join two things which are similar---only like can be used in this case:
No one cares like you / *No one cares such as you
In this sentence, the intended meaning is something like No one cares in the way that you do, and only like can be used for this purpose.
Note that I'd put for first example in this category:
I want a cookie like that
? I want a cookie such as that
It seems to me that this means I want a cookie similar to that one, and such as strikes me as ungrammatical to use here.
Such an interesting question! Such thought-provoking remarks in the comments beneath the question!
Such comments make me wonder, what is the best way to answer such a query? Maybe a few things need to be addressed first, such as:
- What is the meaning of such?
- How is it used in conversation and such?
- What is grammatical, and what sounds natural?
A good online dictionary, such as Wordnik, might help. There, we can find such a great number of meanings and examples, that it will become readily apparent that such a question is not so easily answered. English can be such a hard thing to fully grasp, particularly when dealing with such words – words that can be used in such a myriad of ways! After all, many words, though but one word, can be used as different parts of speech: adjectives, adverbs, pronouns and such; such is one such word.
Really, Ivan, you should go visit such a website, and behold the diverse ways such a simple word can be used. Such a curious man is bound to learn something from such a great smattering of examples!
which is to say, there's no EASY way to tell when to use "such", and when to use "such a" - the word is simply too flexible to nail down in such a fashion...
Best Answer
"Such as" is more formal. However there is another subtle difference.
Consider these two examples:
Reference: http://www.quickanddirtytips.com/education/grammar/like-versus-such-as#sthash.l8VRCYQl.dpuf