Programmatic vs Static Pages

I’m pretty sure Frays covered this in a video but curious others experience with building out pages for there site. At what point are you creating a dynamic listings page? For example, are you creating actually pages for each state and city and rendering results ? or having actual pages for each listing ? Im trying to figure out what the impact is on SEO. Im guessing its just about studying the key words from AHRefs etc.. and thinking about when long tail is just to long.