Import selected columns from sas7bdat file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Import selected columns from sas7bdat file

Utkarsh Singhal-2
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]]

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Import selected columns from sas7bdat file

Peter Dalgaard-2
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 <[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] 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: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Import selected columns from sas7bdat file

ajdamico
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 <[hidden email]> 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 <[hidden email]>
> 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]]
> >
> > ______________________________________________
> > [hidden email] 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: [hidden email]  Priv: [hidden email]
>
> ______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Import selected columns from sas7bdat file

Peter Dalgaard-2
In reply to this post by Utkarsh Singhal-2

> On 10 Aug 2017, at 14:34 , Peter Dalgaard <[hidden email]> wrote:
>
> 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.
>

Gah! A "not" remained after editing. DO send plain text, of course.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Import selected columns from sas7bdat file

Utkarsh Singhal-2
In reply to this post by ajdamico
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>
>> > 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]]
>> >
>> > ______________________________________________
>> > [hidden email] 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: [hidden email]  Priv: [hidden email]
>>
>> ______________________________________________
>> [hidden email] 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.
>
>

______________________________________________
[hidden email] 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.
Loading...