Hi everyone,
In SAS I have a dataset and I need to export that an XML file in UTF-8 encoding. In a particular field, there is a long string with special characters which is getting truncated while exporting to XML. There are other values which has more characters are exported without any issue. But the particular field with issue has more special characters. Requesting your help to get it resolved
Thank you
You seem to be showing a macro that generates PART of a data step.
To know why values might be truncated you need to see the full data step that is being run. And the definition of any input data it is reading.
For example your macro is generating this code:
Field_Special = HTMLENCODE(&Field_ID.);
put '<answer>' Field_Special +(-1) '</answer>';
What is the length defined for the variable FIELD_SPECIAL?
What is the value of the macro variable FIELD_ID? If it is the NAME of a variable then what is the length defined for that variable.
To be extra careful you might try defining FIELD_SPECIAL to be longer. The maximum length for a character variable is 32767 bytes. So try adding this line to the top of the data step where you are going to run the code generated by calling that macro.
length FIELD_SPECIAL $32767 ;
Hello
Can you share sample data and the code you are using?
Make sure the data includes good and bad fields and should be as a data step.
You seem to be showing a macro that generates PART of a data step.
To know why values might be truncated you need to see the full data step that is being run. And the definition of any input data it is reading.
For example your macro is generating this code:
Field_Special = HTMLENCODE(&Field_ID.);
put '<answer>' Field_Special +(-1) '</answer>';
What is the length defined for the variable FIELD_SPECIAL?
What is the value of the macro variable FIELD_ID? If it is the NAME of a variable then what is the length defined for that variable.
To be extra careful you might try defining FIELD_SPECIAL to be longer. The maximum length for a character variable is 32767 bytes. So try adding this line to the top of the data step where you are going to run the code generated by calling that macro.
length FIELD_SPECIAL $32767 ;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.