The first use of Uncle Sam in literature was in the 1816 allegorical book "The Adventures of Uncle Sam in Search After His Lost Honor" by Frederick Augustus Fidfaddy, Esq. An Uncle Sam is mentioned as early as 1775, in the original "Yankee Doodle" lyrics of the Revolutionary War. It is not clear whether this reference is to Uncle Sam as a metaphor for the United States, or to an actual person named Sam. The lyrics as a whole clearly deride the military efforts of the young nation, besieging the British at Boston.
The 13th stanza is:
Old Uncle Sam come there to change
Some pancakes and some onions,
For 'lasses cakes, to carry home
To give his wife and young ones.
Doc Tanner often makes references to Uncle Sam.