BookmarkSubscribeRSS Feed
lle
Calcite | Level 5 lle
Calcite | Level 5

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.

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

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.

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 760 views
  • 0 likes
  • 2 in conversation