Hello,
Here's the code I am using...
data class;
set sashelp.class;
if name="Jane" then do;
name=" Jane"; age = .;end;
run;
libname trans xml "\\...\Documents\Test\XML\test.xml" xmltype=oracle ;
data trans.class noprint;
set class;
run;
libname trans clear;
A part of my xml file looks like that:
<?xml version="1.0" encoding="windows-1252" ?>
<ROWSET>
.
.
.
<ROW>
<Name> Jane</Name>
<Sex>F</Sex>
<Age missing="." />
<Height>59.8</Height>
<Weight>84.5</Weight>
</ROW>
What I would like to get for missing value is:
<ROW>
<Name> Jane</Name>
<Sex>F</Sex>
<Age></Age>
<Height>59.8</Height>
<Weight>84.5</Weight>
</ROW>
I have look through the information on the web and I know that the use of tagset=tagset.sasxmiss could do the job. Does some one know another tagset who will do the task.
This procedure below give me the tagset available on my system:
proc template;
list tagsets;
run;
Obviously, the tagset.sasxmiss is not present. Is it possible to download this sasxmiss tagset or to update my tagsets?
Regards,
Where and how can I update my tagsets for SAS Enterprise Guide 7.11
Writing tagsets is a bit of an art, and I'm not that great at it. But how about:
proc template;
define tagset tagsets.sasxnmis;
parent = tagsets.sasxmog;
notes "SAS-XML generic XML-Data - creates empty tag for MISSING";
define event SASColumn;
start:
ndent;
put '<' ;
put NAME;
put '>' / if exists(missing);
break;
finish:
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 'c:\temp\nomiss.xml' tagset=tagsets.sasxnmis ;
data foo.test; x=1; y=.; z=3; run;
Are you looking for the approach in this example (Usage Note 23621: With the XML engine, how can I only output a node if it's not missing?)?
hello Chris,
I have already tried this code and what it does, it erase the missing value element like that:
<?xml version="1.0" encoding="windows-1252" ?>
<TABLE>
<TEST>
<x>1</x>
<z>3</z>
</TEST>
</TABLE>
And what I would like is:
<?xml version="1.0" encoding="windows-1252" ?>
<TABLE>
<TEST>
<x>1</x>
<y></y>
<z>3</z>
</TEST>
</TABLE>
Moreover, I will be very happy to write my own tagset. If you could refer me a good document on the code use, it will be very appreciated.
Writing tagsets is a bit of an art, and I'm not that great at it. But how about:
proc template;
define tagset tagsets.sasxnmis;
parent = tagsets.sasxmog;
notes "SAS-XML generic XML-Data - creates empty tag for MISSING";
define event SASColumn;
start:
ndent;
put '<' ;
put NAME;
put '>' / if exists(missing);
break;
finish:
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 'c:\temp\nomiss.xml' tagset=tagsets.sasxnmis ;
data foo.test; x=1; y=.; z=3; run;
Thanks for your Help Chris!
It works
Unfortunately, I don't understand the code inside the proc template; Define tagset....
I found a paper nesug 2008. I hope it will help how to write simple tagset...
regards,
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.