The real William Shatner did in fact portray Stanley Milgram in The Tenth Level (1976) which was filmed several years after Star Trek (1966) ended.
In one scene, Winona Ryder's character says she was invited to a party by someone named Saul Horowitz. Horowitz is Ryder's original last name.
Peter Sarsgaard also appeared in Kinsey (2004) which was a film about another controversial researcher in the field of human behavior/psychology.
Harold Ramis was inspired by the real life experiments to write the introduction of Peter Venkman, played by Bill Murray, in the movie Ghostbusters (1984).