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

MacQueen, Don macqueen1 at llnl.gov
Thu Aug 21 21:39:41 CEST 2014


So it¹s now pretty clear that sasexport.get() gave each variable in the
data frame a class of ³labelled². The fix() function likely does not know
what to do with that class. So you want to get rid of the labels, and
possibly other attributes.

I¹s suggest you study the Hmisc help pages for information about labeling.
Perhaps there¹s a function named ³label² or ³labelled². The help page for
sasexport.get() probably has something as well.

Something similar to this (not tested) might do the job:

  for (ic in seq(nrow(mydata))) mydata[[ic]] <- unclass(mydata[[ic]])

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 8/21/14, 10:59 AM, "Jun Shen" <jun.shen.ut at gmail.com> wrote:

>David,
>Thanks for your reply.
>Here is some of the output of str()
>
>'data.frame':	1991 obs. of  5 variables:
> $ SID :Class 'labelled'  atomic [1:1991] 01018 01018 01018 01018 ...
>  .. ..- attr(*, "label")= chr "Subject ID"
> $ DV  :Class 'labelled'  atomic [1:1991] NA 8.52 463 364 240 278 237
>167 83.7 260 ...
>  .. ..- attr(*, "label")= chr "Numeric Result in Standard Unit"
> $ VISI:Class 'labelled'  atomic [1:1991] 1 1 1 1 1 1 1 1 1 7 ...
>  .. ..- attr(*, "label")= chr "Planned Study Day of Visit"
> $ NRT :Class 'labelled'  atomic [1:1991] 0 0.75 1.5 3 4 6 9 12 24 0 ...
>  .. ..- attr(*, "label")= chr "Nominal Relative Time"
> $ TIME:Class 'labelled'  atomic [1:1991] -1.1 0.8 1.5 3 4 ...
>  .. ..- attr(*, "label")= chr "Actual Relative Time"
>
>
>
>
>On Thu, Aug 21, 2014 at 11:53 AM, David Winsemius <dwinsemius at comcast.net>
>wrote:
>
>>
>> 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
>>
>>
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list