Using ATD to send SS (supplementary service) USSD (Unstructured Supplementary Service Data) commands will in the very, very, very best case only work for a small subset (or not at all. When you enter those number using the MMI they are parsed by a completely different entity than the one parsing AT commands).
What you really want to do is to use those AT commands that have specifically been written to support sending SS or USSD. For USSD you use
AT+CUSD=[<n>[,<str>[,<dcs>]]]
See the 3GPP 27.007 specification for details.