You are attempting to apply the user DOC example incorrectly. In your code, an attempt is being made to physically store the FORMAT/CATALOG member onto the libref/fileref OUTPUT, which is why you are getting the error.
Possibly your understanding about SAS and using FORMATs in this process is confused? You should not intend to export the FORMAT/FORMATC CATALOG member with this process. Instead, this process will tell SAS to apply any referenced formats when exporting a SAS member, based on your LIBNAME options specified.
A more accurate SAS coding technique would be to create your SAS user format, outputting it to the WORK libref (leave off the LIBRARY= keyword), then define a SAS DATA step also outputting a SAS data library member to WORK having a numeric type variable and also a FORMAT statement to reference your user format just created. Then, code another DATA step to export you SAS member and you will see how SAS automatically applies the format accessible through your FMTSEARCH= declaration.
Let's get back to start point.
I want to view SAS dataset using SAS Universal Viewer. However, this tool does not support raw SAS format catalog.
It seems that I have to convert the SAS format catalog to an XML file.
I failed to perform the conversion using XML engine.
I am wondering someone can provide an sample code to convert SAS format catalog to XML file, which will be used in SAS Unversal Viewer.
Are you, by any chance, trying to create DEFINE.PDF or DEFINE.XML for CDISC? If so, I believe that you're on the wrong track in trying to store the SAS Format catalog in XML. The XMLTYPE of CDISCODM is -not- meant to be used in a manner such as you show.
It was my understanding that the CDISC related tagset templates for use with the XML Libname engine were really meant to be used "behind" the scenes either by PROC CDISC, by the SAS CDISC viewer or by the new CDISC toolkit and possibly by DI Studio.
For more information about the new CDISC toolkit, refer to: https://www.sas.com/industry/pharma/cdisc/ (where it says: SAS recommends using the SAS Clinical Standards Toolkit to create define.xml instead of PROC CDISC. The toolkit is in active development with several additional releases planned. PROC CDISC is maintenance only – no new features will be added.
Actually, I have no idea. The most I use the Universal Viewer for is to look at .SAS program files or look at SAS Log files.
I did try to open a data set that had custom user defined formats and SAS did NOT use the format -- not surprising because the format catalog is probably not available to the SAS Universal Viewer.
When I highlight a column (such as birthdate, that's formatted with the DATE9. format, clicking the Format button only toggles between the unformatted number and the DATE9 display of the number. I do not see a place where I can specify a different SAS format. I do see the choice under Tools--> Options to point to a SAS format catalog or to an XML User Format file, but I have no idea what an XML User Format file is. You might wish to ask Tech Support this question.