Usage Note 23621: With the XML engine, how can I only output a node if it's not missing?
You can output a node for only the non-missing values by using the
below tagset. This tagset is shipped as a default for SAS 9.1.
proc template;
define tagset tagsets.sasxnmis;
parent = tagsets.sasxmog;
notes "SAS-XML generic XML-Data - does not pad pcdata with blanks and
produces no empty tag for MISSING";
define event SASColumn;
start:
break / if exists(MISSING);
ndent;
put '<' ;
put NAME;
break;
finish:
break / if exists(MISSING);
put '</' ;
put NAME ;
put '>' CR ;
xdent;
break;
end;
define event MLEVDAT;
break / if exists(MISSING);
put ' value="' / if cmp(XMLDATAFORM, "ATTRIBUTE");
put VALUE / if cmp(XMLDATAFORM, "ATTRIBUTE");
put '"' / if cmp(XMLDATAFORM, "ATTRIBUTE");
break / if cmp(XMLDATAFORM, "ATTRIBUTE");
put '>' ;
put VALUE ;
break;
end;
end; /* sasxmiss */
run;
/*run this once (it will write to sasuser) and then to specify it */
/*on the libname */
libname foo xml 'nomiss.xml' tagset=tagsets.sasxnmis ;
data foo.test; x=1; y=.; z=3; run;
Operating System and Release Information
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Type: | Usage Note |
Priority: | low |
Topic: | SAS Reference ==> ODS (Output Delivery System) Third Party ==> Output ==> XML
|
Date Modified: | 2004-01-06 10:45:28 |
Date Created: | 2003-12-24 12:13:06 |