Can I ask for authorship/acknowledgement for writing small data analysis program for a large study?
Asking whether a contribution merits acknowledgement or co-authorship is always appropriate, as long as it is done in a professional and non-confrontational way.

The answer may be "no," but it's certainly worthwhile to ask. (And if the answer is "no," at least you have learned something about standards for authorship and acknowledgement in your lab/field.)