The show 's ratings were lower in later years , series creator Aaron Sorkin ( who wrote or co-wrote 85 of the first 88 episodes ) left the show after the fourth season . It was still popular with viewers who have a high-income . The show 's ratings waned in later years , following the departure of series creator Aaron Sorkin ( who wrote or co-wrote 85 of the first 88 episodes ) after the fourth season , yet it remained popular among high-income viewers , with around 16 million viewers , a key demographic for the show and its advertisers .