以 + [noun] + 为例,[clause]
[subject] + 以 + [noun] + 为例,[verb phrase]
以…为例 introduces an example: "take X as an example", "to use X as an illustration". The example goes between 以 and 为例, and the frame usually opens the sentence, with the point it illustrates after the comma. 为 here reads 为, "as". It is formal – lectures, reports, articles, textbooks.
With a subject, it says what someone used as their example.
It can also follow a general statement, as the illustration of it.
The example goes inside the frame, after 以. English "for example, Beijing" order doesn't carry over.
In conversation, 比如 or 拿…来说 do the same job.