如何在SAS代码中添加回车符?
我想在SAS代码中添加回车符\换行符\换行符,以便输出xml中有回车符。
data test_JK_merge;
length body $ 1500;
set test_JK;
body=strip(termEntry_st)||" "||strip(TS_Status)||strip(langset_en_st)||strip(nttG)||strip(langset_en_ed)||strip(termEntry_ed);
/*merged=strip(termEntry_st)||"'0A'X"||strip(TS_Status)||"<br />"||strip(langset_en_st)||"<br />"||strip(nttG)||"<br />"||strip(langset_en_ed)||"<br />"||strip(termEntry_ed);*/
keep body;
run;
libname outxml xml "U:\Projects\...\test2.mtf.xml";
data outxml.text;
set test_JK_merge;
run;
我尝试过不同的方法,例如 、'OA'X、 、
等 但它们都不起作用。有人可以帮忙吗?
实际结果:
<TEXT>
<body><termEntry id=1> <note type="TS_Status">ELC TERM present in OCS_Help_xml OCS_properties</note><langSet lang="eng-us">ntig><termGrp><term>ARM</term></termGrp></ntig></langSet></termEntry></body>
</TEXT>
预期结果:
<TEXT>
<body><termEntry id=1>
<note type="TS_Status">ELC TERM present in OCS_Help_xml OCS_properties</note><langSet lang="eng-us">ntig><termGrp><term>ARM</term></termGrp></ntig></langSet></termEntry></body>
</TEXT>
I want to add a carriage return\linebreak\linefeed to the SAS code, so that there are returns in the output xml.
data test_JK_merge;
length body $ 1500;
set test_JK;
body=strip(termEntry_st)||"
"||strip(TS_Status)||strip(langset_en_st)||strip(nttG)||strip(langset_en_ed)||strip(termEntry_ed);
/*merged=strip(termEntry_st)||"'0A'X"||strip(TS_Status)||"<br />"||strip(langset_en_st)||"<br />"||strip(nttG)||"<br />"||strip(langset_en_ed)||"<br />"||strip(termEntry_ed);*/
keep body;
run;
libname outxml xml "U:\Projects\...\test2.mtf.xml";
data outxml.text;
set test_JK_merge;
run;
I have tried different ways, such as
, 'OA'X,
,<br />etc
But none of them worked. Does anybody can help out?
Actual result:
<TEXT>
<body><termEntry id=1>
<note type="TS_Status">ELC TERM present in OCS_Help_xml OCS_properties</note><langSet lang="eng-us">ntig><termGrp><term>ARM</term></termGrp></ntig></langSet></termEntry></body>
</TEXT>
Expected result:
<TEXT>
<body><termEntry id=1>
<note type="TS_Status">ELC TERM present in OCS_Help_xml OCS_properties</note><langSet lang="eng-us">ntig><termGrp><term>ARM</term></termGrp></ntig></langSet></termEntry></body>
</TEXT>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,我
对使用 LIBNAME XML 所获得的结果感到有点惊讶。我可能倾向于从 DATA 步骤手动生成 XML。
style=generic(默认)的 LIBNAME XML 将生成以下形式的输出
,即输入文件中的每条记录有一个标记
,其下有一个针对数据集中的每个变量的标记。为了使 SAS 能够读回结果,它将对任何值进行转义,因此,如果数据集中的变量是字符串并包含任何字符<
、&
等它不会“混淆”XML。因此,在您的情况下,如果数据集中的变量具有类似的值,那么我希望 libname XML 的输出类似于
这些选项似乎要么了解如何将 XMLMap 与 LIBNAME XML 结合使用才能生成您想要的 XML(可能无法实现,具体取决于您拥有的 SAS 版本),或者使用 DATA 步骤手动生成 XML:
I'm actually slightly surprised that you get
by using LIBNAME XML. I might be inclined to generate the XML manually from a DATA step.
LIBNAME XML with style=generic (the default) will produce output of the form
i.e one tag
<dsname>
for each record in your input file with a tag under it for each variable in the data set. In order that SAS can then read the result back in it will escape any value, so that if the variable in the data set is a string and contains any of the characters<
,&
etc it won't "confuse" the XML. So in your case, where the variable in the data set has a value something likethen I'd expect the output from libname XML to be something like
The options seem to be either to understand how to use XMLMap with LIBNAME XML in order to generate the XML you want (may not be possible depending on what version of SAS you have), or to generate the XML manually using a DATA step: