Hi,
I'm creating a C# SAS V5 generator (.xpt files).
My output files are stored in .xpt and encoded in ISO-8859-1 (1252 code).
I followed all the SAS documentation for well exporting but i'm facing some problems with my numbers conversion.
E.g., when converting C# int into their floating-point representation, i got some mistakes. I have a unit test exporting my data in .xpt format, then I load them into SAS and read it with %xpt2loc maccro. For sequence number, my 8 is read as "3.9375", my 16 as "A".. It's not random mistakes, it's always the same.
I'm working with Alan Churchill C# converter (december 2012) - https://www.codeproject.com/Articles/492449/Transform-between-IEEE-IBM-or-VAX-floating-point , or maybe you have an other solution ?
Here is a sample of my code,
var converter = new Converter();
converter.Process(Endian.BigEndian);
var bytes = converter.ConvertDoubleToBytes(Platform.IbmFloat, (double)data_);
var byteString = Encoding.GetEncoding(1252).GetString(bytes);
return PadString(byteString, _fieldSizes[index_]);
for a numeric var, _fieldSizes[index_] is always equals to 8.
Hope you can help.
Interesting endeavour.
Sorry I can't help you, but reading your question raised a few thoughts.
1. I would start with a SAS-encoded file and see what the output for your data is.
2. Did you read this and this? Maybe @BarbaraPost can help.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.