Reputation: 4524
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.
Upvotes: 0
Views: 3401
Reputation: 12691
As you point out, the columns in ViewTable do not automatically resize to show entire contents of the variable.
An alternative approach would be to use 'Form View' - available in the toolbar along the top:
This could be assigned to a shortcut key, eg as follows:
dm "keydef F4 'viewtable &syslast view=form'";
Yet another approach (if using a version of base SAS earlier than 9.4) would be to use FS View (credit Jay Stevens) - for example:
dm "fsv sashelp.class";
More info on display manager shortcuts available here.
Upvotes: 1
Reputation: 4524
It appears that the field width in the data view isn't automatically adjusted by the value of the observations. Notice that "full" has a slightly lesser length than "AA" so that the field width cuts off the second "A". Drag the field header over and the 'missing' characters appear.
Upvotes: 1