[R] R and SAS proc format

Frank E Harrell Jr f.harrell at vanderbilt.edu
Wed Mar 7 14:22:38 CET 2007


Ulrike Grömping wrote:
> 
> 
>>>The down side to R's factor solution: 
> 
>>>The numerical values of factors are always 1 to number of levels. Thus, it
> 
>>>can be tough and requires great care to work with studies that have both
> 
>>>numerical values different from this and value labels. This situation is
> 
>>>currently not well-supported by R.
> 
>>>
> 
>>>Regards, Ulrike
> 
>>>
> 
>>>P.S.: I fully agree with Frank regarding the annoyance one sometimes
> 
>>>encounters with formats in SAS! 
> 
>  > You can add an attribute to a variable.  In the sas.get function in the
>  > Hmisc package for example, when importing SAS variables that have PROC
>  > FORMAT value labels, an attribute 'sas.codes' keeps the original codes;
>  > these can be retrieved using sas.codes(variable name).  This could be
>  > done outside the SAS import context also.
>  >
>  > Frank
>  > --
>  > Frank E Harrell Jr   Professor and Chair           School of Medicine
>  >                       Department of Biostatistics   Vanderbilt 
> University
> 
> Frank,
> 
> are these attributes preserved when merging or subsetting a data frame?
> Are they used in R packages other than Hmisc and Design (e.g. in a 
> simple table request)?

no; would need to add functions like those that are used by the Hmisc 
label or impute functions.  And they are not used outside Hmisc/Design. 
  In fact I have little need for them as I always find the final labels 
as the key to analysis.

> 
> If this is the case, my wishlist items 8658 and 8659 
> (http://bugs.r-project.org/cgi-bin/R/wishlist?id=8658;user=guest, 
> http://bugs.r-project.org/cgi-bin/R/wishlist?id=8659;user=guest) can be 
> closed.
> Otherwise, I maintain the opinion that there are workarounds but that R 
> is not satisfactorily able to handle this type of data.

R gives the framework for doing this elegantly but the user has an 
overhead of implementing new methods for such attributes.

Cheers
Frank

> 
> Regards, Ulrike
> 
> 
> *------- End of Original Message -------*


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list