Yes. Make sure you buy a mirror with the correct mount though. There are two mainstream mount types, and some mirrors will need an adaptor to fit.
You will also need at least one more part, if not two. The part you will definitely need is a small plastic piece that covers the wiring and snaps onto the mount. It's black and almost like an elongated triangle. Cars that came stock with the factory autodim mirror were supplied with it. The part number is floating around here and also on Nasioc (and I believe Scoobymods). You may also opt to get the factory mini-harness. This allows you to cleanly take power from the dome lamps.
Finally decide whether you want autodim, with compass, outside temp, and homelink. If you opt for outside temp, you'll need to route a wire from the mirror up to the headliner, then across the windscreen, down a pillar, and out to the nose of the car. Several Subarus have outside temp sensors and the stock location for the probe is tucked behind the grille.
Figure $50 for a used factory autodim/compass unit to several hundred for a new unit with all the options. Gentex makes several mirrors, for example. Again, check the mount and be sure to get the right one.