[R] Import selected columns from sas7bdat file

Utkarsh Singhal utkarsh.iit at gmail.com
Thu Aug 10 15:47:06 CEST 2017


I am able to import the whole data set into R as well, and then select
the required columns. But what I am looking for is to optimize on the
run time, as I only need a few columns out of 100s.

Something similar to what fread (package data.table) provides while
importing from a CSV file.

Utkarsh Singhal
91.96508.54333



On Thu, Aug 10, 2017 at 6:00 PM, Anthony Damico <ajdamico at gmail.com> wrote:
> hi, the sas universal viewer might be a free, non-R way to convert a
> sas7bdat file to non-proprietary formats, not sure if it's windows-only.
> those other formats should be easier to import only a subset of columns into
> R..
>
> https://support.sas.com/downloads/browse.htm?fil=&cat=74
>
> On Thu, Aug 10, 2017 at 7:42 AM, peter dalgaard <pdalgd at gmail.com> wrote:
>>
>> I had a look at this a while back and it didn't seem to be easy. The path
>> of least resistance would seem to be to use SAS itself to create a data set
>> with fewer columns, but of course that requires you to get access to SAS.
>>
>> Otherwise, I think you'd have to modify sas7bdat::read.sas7bdat to drop
>> unselected columns. That function is pure R code, so it might not be quite
>> as hard as it sounds.
>>
>> Incidentally, do teach your mailer to not send plain text. It is not much
>> of a problem this time, but HTML mails can become quite unreadable on the
>> list.
>>
>>
>> -pd
>>
>>
>> > On 10 Aug 2017, at 12:24 , Utkarsh Singhal <utkarsh.iit at gmail.com>
>> > wrote:
>> >
>> > Hello everyone,
>> >
>> > I want to import data from huge sas files with 100s of columns. The good
>> > thing is that I am only interested in a few selected columns. Is there
>> > any
>> > way to do that without loading the full dataset.
>> >
>> > I have tried two functions: (1) read.sas7bdat *[from library
>> > 'sas7bdat']*,
>> > and (2) read_sas *[from library 'haven']. *But couldn't find what I am
>> > looking for.
>> >
>> > Best regards,
>> > Utkarsh Singhal
>> > 91.96508.54333
>> >
>> >       [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > 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.
>>
>> --
>> Peter Dalgaard, Professor,
>> Center for Statistics, Copenhagen Business School
>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> Phone: (+45)38153501
>> Office: A 4.23
>> Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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