TL;DR: If they're 20+ seconds away, don't hold the door. If they're 10+ seconds away, it depends on the person.
I have this issue a lot, especially when it comes to going into my dorm. The outer doors lock automatically when they close, so if I hold the door, I can save someone the hassle of having to get their ID to unlock it again. Plus, the doors are heavy, and not exactly easy to open (or shut!).
In general, I look at a bunch of things:
- How urgent is my destination? Where do I need to get to, and how quickly? There's a balance of convenience, between what's convenient for me and what's convenient for them.
- How long will it be until they reach the door? This is the thing I look at most; see below.
- Are they carrying bags, and are they having any trouble with them? Something like a purse or backpack isn't a huge burden; two heavy suitcases might be.
- Is there anyone else in the vicinity who will go in or out soon after me, and could they hold the door briefly? Maybe it will only take them 5 seconds to hold the door, when it would take me 20.
- Is the person elderly or otherwise infirm? I think most people are generally more respectful to old people, especially if they have a walker, cane, wheelchair, etc. That said, the presence of a handicap button to open the door could help them.
- Do I know this person? Maybe I want to talk to them; maybe I don't want to be rude.
- Does the person see me, and are they hurrying up because they see me holding the door?
Here's how I, in general, judge whether or not to hold the door, based on how long I'd have to wait:
- 0-5 seconds: Hold the door under most circumstances unless I'm literally running somewhere out of urgency. I can spare 5 seconds of my life to be nice to someone.
- 5-10 seconds: If the person is elderly or struggling with bags, then I'll absolutely hold the door. If there's someone who will get to the door after me but before them, though, I'll let the door close if I think that person will hold the door. Again, 5-10 seconds isn't a huge burden for me.
- 10-20 seconds: Is the person is, again, impaired in some way - physically or with luggage - then I'll probably hold the door. Again, though, odds are decent that someone else will come in 5-10 seconds before this other person, if it's a busy enough area.
- 20+ seconds: I'll hold the door only if this person is in some sort of emergency.
Keep in mind that if you hold open the door, the other person may feel obligated to get there quicker - and you don't want an old person to start trying to jog your way if they feel bad for you! Likewise, if someone with bags starts to run, they might end up dropping the bags, which means that you'd have to wait until they pick them all up, which just ends up annoying everyone. You can counteract any potential feelings of guilt by smiling and making it clear that you're just happy to help them out - assuming that's the case.
Just for reference, if a person's walking at 4 miles per hour, then they can travel about 100 meters per minute. So 10 seconds = 16 meters, 20 seconds = 32 meters, etc. 1 meter is about 3 feet, so if the person is less than 50 feet away, you should probably hold the door.
It's sometimes tempting to prop open the door with a doorstop or rock, if you think nobody's going to come by but you have to go. Don't do this. Many places would consider this a security risk, and it could set off (fire/burglar) alarms or let out cold or warm air, depending on the season and heating. People at my college have gotten into trouble for propping over outer doors, mainly for the security reason.
As a final note, I'm a young person, and supposedly energetic and fit. The person may expect (or not expect) you to hold the door, depending on your age and build.