People, I am not a programming genius by any stretch of the imagination. That said, I've done work with a variety of co-authors (Mark Perry, Mrs. Angus, Rodolfo Cermeno, Olan Henry & Nilss Olekalns ) where we write our own code to estimate multivariate GARCH in mean models, which so far are not available as pre-programmed packages in STATA or EVIEWS or SAS.
As a result, I get a fair amount of requests to give code to others. Amazingly to me, many of these requests come from PhD students.
My feeling is that if you are getting a PhD in economics you should write your own code for your dissertation. I usually tell students that and decline to give them the code, but offering to answer any specific questions that they may have about their own coding efforts.
The most bizarre situation I've faced was with a researcher from a central bank in Latin America. He asked for some code and I provided it, but he couldn't get from the code specifically written for my problem and data to a solution to his problem and data. So he asked if he sent me his data would I code up and run the estimations his bosses wanted.
I'd be very interested in hearing in the comments from other researchers how they handle requests to provide code along with any good code-sharing stories.