Are you allowed to install a sub panel in an attic?

How about a service panel?