you could use a slightly different approach. No code required. Note that this will only work if your polygon shapes don't overlap. But as you're talking about states, this should work for you :-
use Query attributes by location from you points layer to your polygon layer, so each point inherits attributes from the polygon it falls inside. Join from your points layer to the polygon layer, and use the "Within" operator, and keep the other defaults ("Take attributes of first located feature", "Only keep matching records"). The latter means that any points not inside a state will not be kept.
use Split vector layer on your joined points layer, and select the field you want to use to separate out the shapefiles. For example, each point should now have the state's name or other identifier.
Both of these options are under Vector > Data Management Tools
TIP: create a new empty directory/folder, and write to there in step 2. This doesn't give you the option (in 2.18 at least) to open the new layers in the canvas once it's finished. Doing this makes it easier to load your shapefiles back in afterwards.
Your shapefiles will be given names in this format
[original_layer_name]_[field name]_[Value].shp