Since you live in one state and live in another you will need to file 2 state tax returns. One for your resident state (NY) and one for your Nonresient state (PA).
On your NY state return you will receive a credit for taxes paid to the nonresident state since you are taxed on all income by your resident state.
Here is the instructions for this as copied from the NY state Tax return:
Line 41 - Resident credit
"Did you have income from sources outside New York State and
pay income tax to another state, a local government of another
state, the District of Columbia, or to a province of Canada? If
No, go to line 42.
If Yes, complete Form IT-112-R, New York State Resident Credit,
and, if applicable, Form IT-112-C, New York State Resident
Credit for Taxes Paid to a Province of Canada. Enter the total
amount of resident credit on line 41 and attach either form or
both forms to your return."
To make this process easier, do your Nonresident return first for PA since you will need information from it to complete your credit for the NY return.
Your federal return should take into account both state taxes withheld regardless which is your resident state.
I hope this information is helpful,