They are correct, but there are subtleties.
"по году не писал писем" would mean 'during some period, much longer than one year, he wrote on rare occasions, approximately 1 letter per year'.
сидеть над книгой по целым дням
To emphasize that during the period-much-longer-than-one-day the person spends most of the time on the reading, you indeed can say "сидеть над книгой/книгами по целым дням".
But most likely, you will see something different: "целыми днями", "с утра до ночи", "весь день напролёт", ...
Example of "по дню" (a quote from Internet): "гонять надо на каждом танке по дню, не меньше": you should drive each tank at least for the one whole day.
Не видал его по целым неделям
What the author wanted to say (again): They saw each other more than once, but the average duration, during which 'someone' did not see 'him', was several weeks.