hex variable loses hex value in xml

Reply
Occasional Contributor
Posts: 11

hex variable loses hex value in xml

Hello,

I created an id variable with this statement

    newId=put(id, hex8.);

Everything looks correct when I browse the data in sas.  The newId variable has the attributes of a character variable with a length of 8.

However, I need to output the variable to a xml file but some of the values have changed once I open the file in Excel.

for example

08398E77  becomes 8.398E+80

or

34E2937   becomes 1.79769313486232E+308

I used proc print and a $8. format.

I used proc report and defined a $8. format for the column.

Neither worked.

I looked at the .XML file and can see <Data ss:Type="Number">34E29237</Data><</Cell>  in the xml code - therefore telling excel to bring in the value as a number.  How can I force it say "String" instead of "Number"?

Julie

SAS Employee
Posts: 340

Re: hex variable loses hex value in xml

Hi, could you attach the code that creates the XML? Thanks.

SAS Employee
Posts: 340

Re: hex variable loses hex value in xml

Probably there are better ways to do it, but here's an example:

data have;

id=100;newId=put(id, hex8.);output;

id=200;newId=put(id, hex8.);output;

id=453;newId='08398E77';output;

id=532;newId='034E2937';output;

run;

ods tagsets.excelxp file='c:\temp\test.xml';

proc print;

  var id;

  var newID / style(column)={tagattr='Type:string'};

run;

ods tagsets.excelxp close;

Occasional Contributor
Posts: 11

Re: hex variable loses hex value in xml

Hello Gergely,

I think the tagattr is what I needed.  I am testing now and do not see the numeric values that were there earlier.

Thank you.

Julie

Esteemed Advisor
Esteemed Advisor
Posts: 7,217

Re: hex variable loses hex value in xml

There is also an option: NUMERIC_TEST_FORMAT

Which is used to decide if a variable is numeric or not.  You could set this to:

NUMERIC_TEST_FORMAT='1.'  (can't remember if it needs the quotes or not), in the options, then anything which isn't in format 1. will be considered a string (hopefully - haven't tested).

Ask a Question
Discussion stats
  • 4 replies
  • 345 views
  • 0 likes
  • 3 in conversation