Independent presidential candidate John B. Anderson campaigned through Pennsylvania today, harshly criticizing his Democratic and Republican opponents' economic policies and reiterating his sober message that there can be "no gains without pains."

In a television interview in Philadelphia, the Illinois congressman denied he is a spoiler who will take votes from President Carter and throw the election to Ronald Reagan. Citing a Roper poll that he said showed that he would take votes equally from Reagan and Carter, Anderson said, "I am giving millions of Americans a choice they would not otherwise have . . . I think this campagin is just beginning."

Anderson criticized Reagan for inconsistency in advocating a large tax cut while at the same time calling for a balanced budget and higher defense spending. As for Carter, he said he would not want it "on my conscience" to reelect a president who had presided over a $63 billion budget deficit after promising a balanced budget, and who had permitted inflation and unemployement to rise dramatically during his term.

Anderson's performance in Sunday's debate with Ronald Reagan seems to have had little effect on this campaign so far except for buoying Anderson's spirits.

His Tuesday night rally in Philadelphia, which filled less than one-third of the civic center, received a disappointing front page review in the Philadelphia Inquirer this morning, headlined "Anderson Momentum Stalled." p

However, Anderson said here today, "I don't think one swallow makes the spring, one debate makes the campaign or that one rally makes all the difference." The debate, he said, has aided the campaign "esprit de corps."

Anderson press secretary Tom Mathews said the Philadelphia rally was "a success . . . terrific," especially considering that the Eagles and the Phillies were both playing on television that night, Mathews said 1,600 seats at $3 each were sold for the 3,200 seat civic center, although reporters counted fewer than a thousand in the hall.

In Harrisburg, where Anderson attracted about 700 people to a noontime rally in the ornate state capitol, he recalled the Three Mile Island accident and was applauded when he called for a moratorium on the construction of nuclear power plants until safety issues are resolved.

In Allentown, Anderson greeted a handful of workers at the highly automated Fairtex Knitting Mill, ignoring a few pickets who criticized his record on labor issues. This afternoon, he received a rousing reception from 2,800 students at Lehigh University in Bethlehem, where he also emphasized his economic recovery program.