According to San Francisco's Friends Of Animal Care And Control "there are an estimated 120,000 dogs in San Francisco," but "only about 20,000 of them" bear a legally-required SF dog license. If those numbers are accurate, that means that there are about 100,000 people walking around the city who can be stopped and searched by police at any time.
The Fourth Amendment to the Constitution prohibits "unreasonable" police searches and seizures (I'm simplifying, you can read more about how the amendment works here), requiring probable cause to do so. The police activity of stop-and-search, also known as stop-and-frisk, walks a Fourth Amendment line (one that's been repeatedly challenged in court) and is explicitly not San Francisco Police Department policy.
However, a police officer can stop and search you if you're breaking the law, of course! That's why, at a community meeting at SFPD's Park Station that was reported on by Hoodline, Sergeant Ron Meyer told attendees that "If you're violating the law, whatever the law is, we'll be talking," and that being in possession if an unlicensed dog was, Hoodline reports, "grounds for a stop-and-search."
While the context of this enforcement tactic was a discussion of how Park Station police manage homeless folks in the Haight, it's worth considering that, should police officers choose, they can apply that to any dog guardian in the city — all estimated 100,000 of you who are sans permit!
According to San Francisco Animal Care And Control's website, "dog licenses are mandatory and must be renewed each year" (though the Treasurer's office says you can purchase a two or three-year license) with late charges assessed for failure to renew any expired licenses.
Newcomers to SF "have 30 days to acquire a San Francisco dog license before a late charge is assessed."
You can get an SF dog license online here, all you need is a copy of your dog's current rabies vaccination certificate and the license fee, which you can determine here. Better that than an SFPD stop-and-search, right?