Used to be that RAW, the sniper wasn't getting the sneak attack. Why? No good reason other than that "a legalistic reading of the rules said so." There are no end of huge threads on paizo.com going over in tortuous detail how vision and stealth and all that work in PF core, especially here and here, and the summary was "slavishly following the rules means things that make no sense." You never get sneak attack from stealth because "you can't stealth while attacking" and "it doesn't say you get sneak attack just because someone can't see you, as hidden isn't an official condition (tm)."
I would previously invoke GM privilege to implement RAI - as in Pathfinder they say clearly "the GM is the law over and above the written rules" - and make it so they get their sneak attack. Because it makes sense from a game world logic/sim point of view and you can rule that's more important than the RAW point of view. IMO the clear intent was to sneak-attack someone from Stealth. You know, "sneak," "attack," things that happen in the real world and every previous edition of D&D.
Can I Attack From Stealth?
Now, however, the Stealth rules have been errata'ed to specifically say "you can attack from stealth" which means that yes, you get the sneak attack. See the updated version on the PRD which says:
Breaking Stealth: When you start your turn using Stealth, you can leave cover or concealment and remain unobserved as long as you succeed at a Stealth check and end your turn in cover or concealment. Your Stealth immediately ends after you make an attack roll, whether or not the attack is successful (except when sniping as noted below).
Sniping: If you've already successfully used Stealth at least 10 feet from your target, you can make one ranged attack and then immediately use Stealth again. You take a –20 penalty on your Stealth check to maintain your obscured location.
So the RAW has been updated to match the RAI for whatever that's worth (apparently it's really meaningful to some, though all my rogues have been happily sneak attacking from Stealth since the year 2000...).
Does A Stealthed Attack Enable Sneak Attack?
Yes, if you're stealthed, your attacks are sneak attacks.
Jason Buhlman states the intent clearly on the Paizo forums:
For simplicities sake, it should be assumed that those making Perception checks get to do so at the most favorable point during the movement of a character using Stealth, to avoid making checks every time the condition changes. Technically, I think you would get a check whenever the conditions change, but that might make things overly complicated during play.
Creatures are denied their Dexterity bonus to AC "if they cannot react to a blow" (CR pg 179 under AC). It was our intent that if you are unaware of a threat, you cannot react to a blow. I think we probably should have spelled this out a wee bit clearer, but space in the Stealth description was extraordinarily tight and ever word was at a premium. That said, I think these changes clear up the situation immensely (compared to where they were.. which was nebulous at best).
They didn't bother changing the RAW because most people use common sense and play it that way. Stealthed = sneak, etc.
RAW + Pathfinder = Sad Panda
This is why, whether you like this or not, a pure RAW approach to Pathfinder is always going to be frustrating; the devs explicitly don't bother to clean up RAW when RAI and/or common sense is clear. It's not a priority of theirs and I for one am pretty happy about that - they spend their intellectual capital making new interesting fun content instead of crafting rules and just retreading the same content year after year like WotC did with 3.5 (Return to the Return to the 1e Module, anyone?).
'Attacks' or 'attack roll' both refer to the attack roll only, not damage. If damage should be included, it is explicitly mentioned.
So fighting defensively gives a -4 penalty to attack rolls only. Damage is unchanged.
If you look at it thematically, it would make sense for the character's swing to be less precise while fighting defensively (and thus give a penalty on the attack roll, resulting in a higher chance of miss). IF he/she would hit, though, the damage his/her weapon would do should still be the same (i.e same weapon, same force behind the swing, etc)
Best Answer
[Note to those who have up-voted this answer: I've posted an alternate theory, prompted by @Escoce, which I ask you to consider. Perhaps you find that compelling and wish to retract your vote here.... -nitsua60]
What you call a "non-damage attack" I'd call a contest
To be clear: it's not obvious to me that all non-damaging hostile actions must necessarily be contests. But the example you ask about seems to be one. Here's why:
You don't want to attack with the sand...
Since sand isn't a weapon, per se, you'd have to treat it as an improvised weapon. But the only thing the improvised weapon rules are built to handle is damaging your target, which isn't your goal.
You want to blind.
We're pitting your "throwing sand" prowess against your opponent's "closing eyes in time" prowess. (That's my read, at least.) Is that contest described? Nope. But:
So what's the resulting contest look like?
Contests are something you need to improvise yourself, but here's how I'd handle it. I'll explain the thought process behind this one afterwards:
(Picking up the sand is interact with object, and the DEX check takes up one of your attacks on your turn.)
Here's my thinking behind creating it this way:
Picking up the handful of sand is an easy "interact with object", since it's at least easier to just grab whatever-your-hand-hits than to pick up a dropped axe (the example given on PHB p.190).
You use your Attack action to throw the sand. As with both Grappling and Shoving, if you can make multiple attacks with your Attack this replaces one (PHB p.195).
Decide how, exactly, the checks will be contested. Both throwing and dodging the sand have to be DEX checks, as thrown weapons and dodging magical effects implicate DEX modifiers and DEX saves, respectively. Are any of the skills relevant? I don't find the descriptions of Acrobatics, Sleight of Hand, or Stealth particularly apropos, so I'd rule straight-DEX.
What are the effects of success? Being blinded makes the target auto-fail checks relying on sight, disadvantages target's attacks, and advantages attacks against the target (PHB p.290). That seems a little harsh, but creating a dialed-down custom condition will become way too complex. Maybe we can tune it down with how the blindness ends though:
Clearing the sand out of one's eyes: being magically blinded allows for a CON save every turn (Blindness/Deafness, PHB p.219). I think the sand should be no harder than that to clear away. The CON save for the spell is against the caster's spell save DC, almost certainly >= 13. So maybe you go with sand has a CON save of 10 for ending the condition.
I'm going to make a few more concessions to the target: they can use an action to try to clear, and the sand'll clear away naturally after a certain duration. (That's what tears are for!) I didn't want to run the experiment at home, but 18 seconds (3 turns) seemed reasonable to clear it away. I tell my kids, when somethings in their eyes, to "close your eyes, count backwards from ten, and blink five times." If it works in the (literal) sandbox, it's sure to work in battle. Right?
So, we end up with a quick DEX check with some concessions for a relatively easy save-ends.
The question Can I give the blinded condition through an improvised action? ends up looking at the same situation: flinging sand at an opponent. The accepted answer there disagrees with mine, making that question is a good place to look at an argument against my interpretation.