BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mk131190
Obsidian | Level 7

Hello,

 

I have a SAS dataset I need to export to XML in the following format:

 

<t i="Title">
<R var1="11111111111" var2="22" var3="22222" var4="1234.12" />
<R var1="222222222" var2="33" var3="111111" var4="2345.23" />
<R var1="333333333" var2="22" var3="22222" var4="1234.12" />
<R var1="444444444" var2="33" var3="111111" var4="2345.23" />
<R var1="555555555" var2="22" v="22222" var4="1234.12" />
<R var1="666666666" var2="33" var3="111111" var4="2345.23" />
<R var1="777777777" var2="22" var3="22222" var4="1234.12" />
<R var1="888888888" var2="33" var3="111111" var4="2345.23" />

 

Is this possible?

 

Thanks,

 

Mark

1 ACCEPTED SOLUTION

Accepted Solutions
Oligolas
Barite | Level 11

yes,

 

DATA _NULL_;
   length var $32767;
   file "C:\test.xml";
   set sashelp.class;
   if _N_ eq 1 then put '<t i="Title">';
   else do;
      var='<R name="'||strip(name)||'" height="'||strip(put(height,best.))||'" weight="'||strip(put(weight,best.))||'" age="'||strip(put(age,best.))||'" />';
      put var;
   end;
RUN;

Cheers

________________________

- Cheers -

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes.  Many ways to do it.  What have you tried?  You could do this with a datastep and put each of the values out to a file.  Simple.  However that snippet you provide doesn't look very XML to me.  Either your using some weird properties on your XML, or that is something else, maybe HTML.  Clarify your problem - what data do you have - post it as a datastep in the post.  Show the full output of what you want.  This shows how to output actual XML:

http://www2.sas.com/proceedings/sugi29/119-29.pdf

Oligolas
Barite | Level 11

yes,

 

DATA _NULL_;
   length var $32767;
   file "C:\test.xml";
   set sashelp.class;
   if _N_ eq 1 then put '<t i="Title">';
   else do;
      var='<R name="'||strip(name)||'" height="'||strip(put(height,best.))||'" weight="'||strip(put(weight,best.))||'" age="'||strip(put(age,best.))||'" />';
      put var;
   end;
RUN;

Cheers

________________________

- Cheers -

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 972 views
  • 2 likes
  • 3 in conversation