Publications by Eric Cai - The Chemical Statistician

Use the LENGTH statement to pre-set the lengths of character variables in SAS – with a comparison to R

16.08.2017

I often create character variables (i.e. variables with strings of text as their values) in SAS, and they sometimes don’t render as expected.  Here is an example involving the built-in data set SASHELP.CLASS. Here is the code: data c1;      set sashelp.class;      * define a new character variable to classify someone as tall or short;...

2104 sym R (1401 sym/4 pcs) 16 img 2 tbl

Use unique() instead of levels() to find the possible values of a character variable in R

10.03.2018

When I first encountered R, I learned to use the levels() function to find the possible values of a categorical variable.  However, I recently noticed something very strange about this function. Consider the built-in data set “iris” and its character variable “Species”.  Here are the possible values of “Species”, as shown by the l...

1980 sym R (345 sym/3 pcs)