BookmarkSubscribeRSS Feed
TimHare
Calcite | Level 5
Is there any documentation about how to create an Atom feed using ODS with XML or the XML LIBNAME engine?

There are two possibilities I'd like to learn about, the first creating an Atom feed with items that contain just "text"; the other embedding graphics into the feed.
In either case, it would also be good to know if you can add new items to the top or bottom of an existing feed.
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
So your question is not just 1 question -- it's more like 2 questions. Here's the deal.

1) Can ODS create an XML file? Yes -- ODS can create an XML file using the pre-defined tagset templates that are stored in SASHELP.TMPLMST. If you use one of the pre-defined tagset templates, then you get the XML tags (or HTML tags or WML tags or DOCBOOK tags) that are built into the tagset definition. (BTW, the SAS XML Libname Engine can also create XML files -- and if you are doing your web feed based on a data source, you might want to investigate using the SAS XML Libname Engine instead of ODS to create your XML file.) For example, one of the pre-defined tagsets for use with the SAS XML Libname engine is the Oracle tagset template -- this would write data out in a form designed to be read or consumed by Oracle. On the other hand, one of the pre-defined XML tagset templates for use with ODS is the DOCBOOK tagset template, which creates documents which conform to the OASIS standard for DOCBOOK tags.

2) Can ODS create an ATOM XML file for web feeds??? The answer to this is NO...not by default -AND- YES, if you make your own custom tagset template that creates ATOM conforming tags. Because there is no tagset template among the pre-defined tagsets for creating an ATOM XML file according to the ATOM spec, you would have to design your own tagset template.

If I go to http://en.wikipedia.org/wiki/Atom_feed it says that:

"The name Atom applies to a pair of related standards. The Atom Syndication Format is an XML language used for web feeds, while the Atom Publishing Protocol (AtomPub or APP) is a simple HTTP-based protocol for creating and updating web resources.

Web feeds allow software programs to check for updates published on a website. To provide a web feed, a site owner may use specialized software (such as a content management system) that publishes a list (or "feed") of recent articles or content in a standardized, machine-readable format. The feed can then be downloaded by programs that use it, like websites that syndicate content from the feed, or by feed reader programs that allow Internet users to subscribe to feeds and view their content.

A feed contains entries, which may be headlines, full-text articles, excerpts, summaries, and/or links to content on a website, along with various metadata.

The Atom format was developed as an alternative to RSS. Ben Trott, an advocate of the new format that became Atom, believed that RSS had limitations and flaws—such as lack of on-going innovation and its necessity to remain backward compatible— and that there were advantages to a fresh design.[1]

Proponents of the new format formed the IETF Atom Publishing Format and Protocol Workgroup. The Atom syndication format was published as an IETF proposed standard in RFC 4287, and the Atom Publishing Protocol was published as RFC 5023."



Wikipedia Example of an Atom Feed:
[pre]
<?xml version="1.0" encoding="utf-8"?>

<feed xmlns="http://www.w3.org/2005/Atom">

<title>Example Feed</title>
<subtitle>A subtitle.</subtitle>
<link href="http://example.org/feed/" rel="self" />
<link href="http://example.org/" />
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
<updated>2003-12-13T18:30:02Z</updated>
<author>
<name>John Doe</name>
<email>johndoe@example.com</email>
</author>

<entry>
<title>Atom-Powered Robots Run Amok</title>
<link href="http://example.org/2003/12/13/atom03" />
<link rel="alternate" type="text/html" href="http://example.org/2003/12/13/atom03.html"/>
<link rel="edit" href="http://example.org/2003/12/13/atom03/edit"/>
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
<updated>2003-12-13T18:30:02Z</updated>
<summary>Some text.</summary>
</entry>

</feed>

[/pre]

The kind of XML that represents the ATOM XML looks more like the XML created by the SAS XML Libname Engine, than the XML created by ODS. So, for example, if you run the code below and compare the 2 outputs in Notepad, you will see what I mean. (Note that all 3 files created by ODS are XML files, I just give them a file extension of '.TXT' so I can open each file with Notepad.)

Depending on what version of SAS that you have, you can create custom XML by
1) writing your own custom tagset template for use with SXLE or ODS or
2) use an XMLMAP file to create custom XML based on mapping from a SAS dataset to the XML tags you need (must have SAS 9.2 for this feature -- using an XMLMAP for Export)

For more information about ODS MARKUP and TAGSET templates or SXLE and tagset templates, refer to these sites:
SXLE: http://support.sas.com/rnd/base/xmlengine/index.html
ODS Markup: http://support.sas.com/rnd/base/ods/odsmarkup/
http://support.sas.com/documentation/cdl/en/odsug/61723/HTML/default/a002565723.htm

cynthia

[pre]
*** SXLE method -- exporting a dataset to XML table form;
libname sxleout xml 'c:\temp\made_libname_eng.xml';

data sxleout.class;
set sashelp.class(obs=3);
run;

libname sxleout clear;


** ODS method -- using PROC PRINT to generate the default XML file;
** using 3 different types of markup language.;
ods docbook file='c:\temp\made_docbook.txt';
ods latex file='c:\temp\made_latex.txt';
ods markup tagset=default file='c:\temp\made_ods.txt';
proc print data=sashelp.class(obs=3) noobs;
run;
ods _all_ close;
[/pre]

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1891 views
  • 0 likes
  • 2 in conversation