If I play Piercing Light and there is no unit at a battlefield to begin with but there is a unit in base, can 2 damage still be dealt to the unit in base?

No, you cannot play Piercing Light if there is no unit at a battlefield to target.

According to the card text, Piercing Light requires you to "Deal 2 to a unit at a battlefield" as the first part of its effect. Because this is a mandatory action required to initiate the spell's resolution, you must have a valid target at a battlefield to play the card.

While the "then" in the spell text allows the second part of the effect to resolve even if the first target is removed after the spell is played, the spell cannot be played in the first place if there is no valid target for the initial, mandatory effect.