[R] How to view the whole dataset that is imported through sasxport.get

David Winsemius dwinsemius at comcast.net
Thu Aug 21 17:53:12 CEST 2014


On Aug 21, 2014, at 7:20 AM, Jun Shen wrote:

> Dear list,
> 
> I used sasxport.get to import a SAS xpt file. Although it is a data frame
> but i can't view it through the "fix" command. Also when I see its
> structure, it brings up attributes I am not really interested in (which
> seems part of the SAS labels) and it doesn't seem to tell me the mode of
> each column. How do I suppress those attributes and view it through "fix"?
> Thanks.

It would have helped a lot if you had offered outout of: str(dataset)

I don't use fix() so I'm not sure I help you there. I do notice in looking at the documentation that the function may return a list of dataframes rather than just a dataframe, so perhaps you need to extract the dataframe object. (Just a guess.)

 I generally look at my files with names(), and Hmisc::describe() and use table() for the factor or character values that I expect to have manageable numbers of discrete categories. (Using `fix()` to edit gigabyte sized objects is the way to madness.) You should probably read the Posting Guide because you are failing to mention that the sasxport.get() function is part of the Hmisc package. If you want to get rid of your attributes (which is where the labels are stored)  then the attr() function should allow you to NULL them out:

> x <- 1:10
> attr(x,"dim") <- c(2, 5)
> 
> x
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    3    5    7    9
[2,]    2    4    6    8   10
> attr(x,"dim")
[1] 2 5
> attr(x,"dim") <- NULL
> x
 [1]  1  2  3  4  5  6  7  8  9 10

It also appears the there is a `label<-` function, so you could probably use that to NULL them out.

-- 

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list