** reposted to fix typos **
"Is it a good idea to buy for (perhaps) such a short period?"
Almost certainly not. Its really just a math problem.
Since you're buying a co-op, you'll need a 20% downpayment, plus closing costs in NY tend to be 2-4%, then you'll pay another 7-9% to sell your property when you move (6% to realtor, 1-3% closing costs, transfer tax, etc). So say you buy a 300k co-op, you'll need 60k right now to put down, plus another 6-12k for closing costs right now. Say it goes up to 360k in 3 years, 6.25% increase per year, which is much higher than usual so probably unrealistic, but we'll use it. You will then pay another 25.2k to 32.4k to sell the place. We'll give you a 30 yr fixed at 6%, which may not be attainable, but if you're going in 3 years, get a 5 or 7 year ARM for some cushion and the improved rate. Anyway, so your monthly payment for mortgage and maintenance will be ~2k/mo. I used this apt for cost and maintenance: http://realestate.nytimes.com/sales/detail/221-837227.
So to buy for 3 years(i'll use 2% and 8% for closing costs for simplicity):
you will pay:
~2k/mo in monthly payments or 72k over 3 years
when you sell, you will receive:
91.2k proceeds from sale (120k - 28.8k closing costs)
66k of that 91.2k was yours to begin with, so you make 25.2k.
So for 3 years, you 46.8k for shelter, 72k in payments - 25.2k in profit.
If you were to rent, say you rent this apt: http://newyork.craigslist.org/mnh/fee/740227114.html
for $1290 a month, and you take your 66k and buy a 3 year CD at 4.36% (today's national avg). We'll assume rent will rise at 5% each year, which is high, but ok, and a 1 month broker fee to rent. renting will look like this:
Year 1: $16770 (1290 * 12 + 1290 fee)
Year 2: $16254
Year 3: $17066
Total: = $50090
3 year CD will return $13165
So your cost of shelter for 3 years will be $50,090 - $13,165 = $36,925
So using these number, which are EXTREMELY generous to the purchase side of the equation, it will be ~$10,000 cheaper to rent than to buy. This doesn't take into account the tax benefits you can get from purchasing, although counting on those is getting dangerous as there is talk of the next administration repealing the mortgage interest deduction which will decimate housing. Also, if you do not itemize today, you won't be getting a full deduction anyway, only the difference between the standard deduction and you're new itemized amount. I also assumed housing in manhattan will grow at 6.25% for the next 3 years when we are facing a housing decline and a national credit crunch. Its much more likely that the price you pay today will be the same as the price you sell for in 3 years, then the closing costs for selling will be a bit smaller, but you won't have 60k in profit, so you'll be looking at a huge red number. I assumed a 5% increase annually in rent which is high, and had you invest your downpayment in a CD which generally is one of hte lowest investment returns, but its guaranteed, so it could make sense in the current economy.
Either way, you should look around for rent/buy calculators yourself and check the area you're looking in for prices to purchase and prices to rent. Even in manhattan the equation is way in favor of renting after the current runup in prices. The best thing you can do is educate yourself and make an informed decision. Good luck.