Encyclopaedia Judaica says that “Nothing is known of the early life of Shammai except for the statement that he was a builder by occupation (Shab. 31a).” But that passage, the standing on one foot story, doesn’t say he was a builder. It just says he hit someone with a builder’s cubit-measure. Do any of the commentaries explicitly infer that he was a builder by trade, or else where does this idea come from?
The idea comes from the following passage in Shabbat 31a:
"There was another incident involving one gentile who came before Shammai and said to Shammai: Convert me on condition that you teach me the entire Torah while I am standing on one foot. Shammai pushed him away with the builder’s cubit in his hand. (This was a common measuring stick and Shammai was a builder by trade.) The same gentile came before Hillel. He converted him and said to him: "That which is hateful to you do not do to another; that is the entire Torah, and the rest is its interpretation. Go study."
And Ben Yehoyada says on that passage:
" והנה לפי פשט המאמר שמאי היה מתפרנס במלאכה זו, שדרכם היה לבנות הבנאי את הבית, ובעבור שכרו יביא אחד בקי לתת ערך לשכר הבנין, וזה צריך לו אמה בידו למדוד בה עובי הכותלים וארכן ורחבן, ויהיה חכם בתשבורת כי יש כותל ראשו אחד עב והולך ומתמעט העובי בהדרגות עד סופו ויש להפך, ועוד בזה יש אופנים שונים וצריך חכם גדול בקי בחשבון ותשבורת לתת ערך לכל חלק בפני עצמו, וזו היתה מלאכתו של שמאי הזקן שיהיה מעריך, ולכן תמיד אַמַּת הַבִּנְיָן בידו שבה מודד והיא כלי אומנות שלו."
Translation: "And according to the simple understanding of the passage [previously he brought a drashic interpretation] Shammai would earn money from this type of work, for their way was to have a builder build the house and as his salary, they would bring one who was knowledgeable to calculate the monetary worth of the building process, and this person needs a cubit in his hand the thickness of the walls and their length and width, and he would need to be knowledgeable in trigonometry, for there is a wall which is thick on one end and becomes thinner continuously, and there are those that are the other way around, and there are other aspects and for this one needs to be greatly knowledgeable in math and trigonometry to calculate the worth of every part by itself, and that was the job of Shammai, to be one who calculates, and for this the builder's cubit was always in his hand and with it he would measure and it was his tool of the trade."