I personally don't focus too much on ratings when I write a story. Just cause I know how I might see it in my head, will not be the same thing that is actually shown. Like creativexec said, during production they might be aiming for a particular rating but the writer has no control over that.
The writer may have written a script that in his mind, could easily be an NC-17 film. But produced could be a strong PG-13 or light R. Either way, it's completely out of his control.
I do take into account things like, cuss words, violence, sex, gore, things along those lines when writing, but that's more for storytelling reasons (Is it necessary to the story?). Most of the time, I come up with an answer of "no, it isn't".