When I set a character's variable length to 2 bytes, the data set only shows one character. However, when I print it, the full input displays. To make things even weirder, when I change only the variable name, the problem goes away. Below are code samples accompanied by screen shots of my data views and PROC PRINT results.
I am using SAS 9.4 on Windows 7. I'm not sure what encoding is being used. As I've never changed it, I assume my encoding is wlatin1
, as per this white paper. This should mean that each ASCII character is 7 bits. So, a length
of 2.
should be 16 bits, leaving 2 bits remaining when storing "AA".
I'm at a loss to explain what is going on and am concerned that I may be inadvertantly losing data.
data test1;
length cut $ 1.
full $ 2.
;
cut = "AA";
full = "AA";
run;
proc print data = test1;
run;
I find that if I change the name of the variable, but keep everything else the same, the input displays properly in the data set as well as the output.
data test2;
length one_byte $ 1.
two_bytes $ 2.
;
one_byte = "AA";
two_bytes = "AA";
run;
proc print data = test2;
run;
Below are screen shots of my data views and results window.