Depends.....are you talking about a Electrical Closet or a Clothes Closet?
The NEC is clear that the panel can't go in a clothes closet but it was not until the 2008 NEC that we get a BETTER description of a clothes closet.
You have to make sure you have the required clearances....36" Front, 30" Width and make sure you can maintain the dedicated space requirements of 110.26
240.24(D)
(D) Not in Vicinity of Easily Ignitible Material. Overcurrent
devices shall not be located in the vicinity of easily
ignitible material, such as in clothes closets.
In 2008 we finally get a definition :
Clothes Closet. A non-habitable room or space intended
primarily for storage of garments and apparel. [ROP 1-20]
If the closet you are speaking of is not a "Clothes Closet" then it could have the panelboard within it...provided it meets the space clearances and personally if I was inspecting it...it better not have a clothes hanging rod in it...lol
Just my opinions...I am sure someone will not agree...happens alot it seems.
FYI....
110.31 Enclosure for Electrical Installations. Electrical
installations in a vault, room, or closet or in an area surrounded
by a wall, screen, or fence, access to which is
controlled by a lock(s) or other approved means, shall be
considered to be accessible to qualified persons only. The
type of enclosure used in a given case shall be designed and
constructed according to the nature and degree of the hazard(
s) associated with the installation.
For installations other than equipment as described in
110.31(D), a wall, screen, or fence shall be used to enclose
an outdoor electrical installation to deter access by persons
who are not qualified. A fence shall not be less than 2.1 m
(7 ft) in height or a combination of 1.8 m (6 ft) or more of
fence fabric and a 300-mm (1-ft) or more extension utilizing
three or more strands of barbed wire or equivalent. The
distance from the fence to live parts shall be not less than
given in Table 110.31.
This is why it was important to I guess define what a clothes closet is...thanks 2008 NEC