As mentioned earlier, SGML is only used when writing a DTD. This is not strictly true. There is certain SGML syntax that you will want to be able to use within your documents. For example, comments can be included in your document, and will be ignored by the parser. Comments are entered using SGML syntax. Other uses for SGML syntax in your document will be shown later too.
Obviously, you need some way of indicating to the SGML processor that the following content is not elements within the document, but is SGML that the parser should act upon.
These sections are marked by <! ... > in your document. Everything between these delimiters is SGML syntax as you might find within a DTD.
As you may just have realized, the DOCTYPE declaration is an example of SGML syntax that you need to include in your document...