- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I've a dataset which has only this variable called 'X' and it has value as Fraais:<BR/>indexion<BR/>Vlams:<BR/>indetie
I've to convert this dataset to XML file which should have contents as follows. I'm not certain how to instruct SAS to treat each line break (<BR/> to enter the text in next line.
<explanation>Fraais:
indexion
Vlams:
indetie </explanation>
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Individual put statements will always cause a newline in the text file:
data _null_;
file '$HOME/sascommunity/babloo.xml';
put '<explanation>Franc:';
put 'indexat';
put 'Vlaam:';
put 'indexae </explanation>';
run;
Resulting file:
<redacted>/sascommunity $ cat babloo.xml <explanation>Franc: indexat Vlaam: indexae </explanation>
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I should have asked the question in this way. I've a dataset which has only this variable called 'X' and it has value as Fraais:<BR/>indexion<BR/>Vlams:<BR/>indetie
I've to convert this dataset to XML file which should have contents as follows. I'm not certain how to instruct SAS to treat each line break (<BR/>) to enter the text in next line.
<explanation>Fraais:
indexion
Vlams:
indetie </explanation>
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
See if this: https://stackoverflow.com/questions/35504890/how-to-add-a-newline-line-break-in-xml-file can give you useful hints.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Given link deals with only XML part and not from SAS with XML. Also I'm not certain to fit guidelines mentioned in the link below to my SAS program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Babloo wrote:
Given link deals with only XML part and not from SAS with XML. Also I'm not certain to fit guidelines mentioned in the link below to my SAS program.
Just add the suggested strings to your put statements or to the variables you use in the put. Quite simple, very basic data step technique. Should not pose a problem to someone who's already a veteran here (after 500+ posts)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want; str='Fraais:<BR/>indexion<BR/>Vlams:<BR/>indetie'; str=tranwrd(str,'<BR;/>','0A'x); run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It has not resolved the issue either. I'm getting the same value in row instead of multiple rows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Just saying it didn't work doesn't help. Show your code, is it possible your doing this on Windows and opening in Notepad, then you likely need to replace with Linefeed + CR characters as that is Windows standard. I can't guess!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I just added the following two lines in my SAS program which creates the XML file and ran it via SAS EG. After the successful run, I could see that XML file has generated with the below highlighted part in one line instead of 4 lines.
str='Fraais:<BR/>indexion<BR/>Vlams:<BR/>indetie'; str=tranwrd(str,'<BR;/>','0A'x);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you just put str to the text file, it's contents will be in one line. If you want the lines to break, use several put statements, as I already told you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Not sure why you would want to, visually it does not matter as the whole text between the two tags is read in, you will just end up with linefeeds if you force them in.
<explanation> Franc: indexat Vlaam: indexae </explanation>
Is effecively what the XML should look like. If you want Franc and Vlam separated then these should come under separate tags:
<explanation> <Franc> indexat </Franc>
<Vlaam> indexae </Vlaam> </explanation>
Anyways if you continue, in your data you can add the hex character '0A'x to give returns like:
data want; set have; substr(line,14,1)='0A'x; run;