Quantcast

How to import SAS data in R?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to import SAS data in R?

tmrsg11
Hi all
I have a large SAS data set, how do I get it read in R?

The data is too big (about 400,000 rows by 100 columns) to be saved as an
Excel file.  How should I get it read in R?  Any packages?  I don't seem to
find any.
Thanks,
Mike

        [[alternative HTML version deleted]]

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

Re: How to import SAS data in R?

Jeff Newmiller
You need to learn how to search.

RSiteSearch("SAS")

or

Google : R "read SAS"
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<[hidden email]>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.

C W <[hidden email]> wrote:

>Hi all
>I have a large SAS data set, how do I get it read in R?
>
>The data is too big (about 400,000 rows by 100 columns) to be saved as
>an
>Excel file.  How should I get it read in R?  Any packages?  I don't
>seem to
>find any.
>Thanks,
>Mike
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] 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.

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

Re: How to import SAS data in R?

Duncan Murdoch-2
In reply to this post by tmrsg11
On 06/07/2012 1:11 PM, C W wrote:
> Hi all
> I have a large SAS data set, how do I get it read in R?
>
> The data is too big (about 400,000 rows by 100 columns) to be saved as an
> Excel file.  How should I get it read in R?  Any packages?  I don't seem to
> find any.

You could write it out in some plain delimited format, e.g. CSV or
tab-delimited.  Watch out for special characters in strings that confuse
R when it reads it in (e.g. commas in unquoted CSV strings, quotes
within strings, etc.)

Duncan Murdoch

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

Re: How to import SAS data in R?

Marc Schwartz-3
In reply to this post by tmrsg11

On Jul 6, 2012, at 12:11 PM, C W wrote:

> Hi all
> I have a large SAS data set, how do I get it read in R?
>
> The data is too big (about 400,000 rows by 100 columns) to be saved as an
> Excel file.  How should I get it read in R?  Any packages?  I don't seem to
> find any.
> Thanks,
> Mike


Strangely enough, there is an entire manual on importing and exporting data to/from R:

  http://cran.r-project.org/manuals.html

Several suggestions there for SAS in the relevant manual:

  http://cran.r-project.org/doc/manuals/R-data.html#Importing-from-other-statistical-systems

Regards,

Marc Schwartz

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

Re: How to import SAS data in R?

tmrsg11
In reply to this post by Duncan Murdoch-2
Quick question, what the memory size in R?
I converted to CSV, but only 53300 of the 1,000,000 rows were read in.  Did
R run out of memory?  If so, is there a work around?

Thanks,
Mike

On Fri, Jul 6, 2012 at 1:24 PM, Duncan Murdoch <[hidden email]>wrote:

> On 06/07/2012 1:11 PM, C W wrote:
>
>> Hi all
>> I have a large SAS data set, how do I get it read in R?
>>
>> The data is too big (about 400,000 rows by 100 columns) to be saved as an
>> Excel file.  How should I get it read in R?  Any packages?  I don't seem
>> to
>> find any.
>>
>
> You could write it out in some plain delimited format, e.g. CSV or
> tab-delimited.  Watch out for special characters in strings that confuse R
> when it reads it in (e.g. commas in unquoted CSV strings, quotes within
> strings, etc.)
>
> Duncan Murdoch
>

        [[alternative HTML version deleted]]

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

Re: How to import SAS data in R?

David Winsemius

On Jul 6, 2012, at 1:39 PM, C W wrote:

> Quick question, what the memory size in R?
> I converted to CSV, but only 53300 of the 1,000,000 rows were read  
> in.  Did
> R run out of memory?  If so, is there a work around?

You probably have mismatched quotes. Consider using quote="". Also  
consider doing this:

table(count.fields(file-name)) # with a valid file name

That count.fields function is very useful since it accepts the same  
arguments as the read.tables functions, with defaults of:

  quote = "\"'", skip = 0, blank.lines.skip = TRUE, comment.char = "#")

--
David.

>
> Thanks,
> Mike
>
> On Fri, Jul 6, 2012 at 1:24 PM, Duncan Murdoch <[hidden email]
> >wrote:
>
>> On 06/07/2012 1:11 PM, C W wrote:
>>
>>> Hi all
>>> I have a large SAS data set, how do I get it read in R?
>>>
>>> The data is too big (about 400,000 rows by 100 columns) to be  
>>> saved as an
>>> Excel file.  How should I get it read in R?  Any packages?  I  
>>> don't seem
>>> to
>>> find any.
>>>
>>
>> You could write it out in some plain delimited format, e.g. CSV or
>> tab-delimited.  Watch out for special characters in strings that  
>> confuse R
>> when it reads it in (e.g. commas in unquoted CSV strings, quotes  
>> within
>> strings, etc.)
>>
>> Duncan Murdoch
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

David Winsemius, MD
West Hartford, CT

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

Re: How to import SAS data in R?

David Winsemius

On Jul 6, 2012, at 2:49 PM, C W wrote:

> Hey, David
>
> table(count.fields()) is telling me have 11 columns, but I have way  
> more, more like 30 columns.
> > table(count.fields("persistency.csv"))
>
>      1      2      3      4      5      6      7      8      9     11
> 439384  39617  16130  21993  12556   1900    988    713     61      1
>

I don't usually put back the list address when responding to a private  
email, but I'm breaking my rule. You should not send private follow-
ups for threads that start on the list unless there is something that  
other readers might not benefit from seeing.

  If it is a CSV file then you need to tell count.fields to use commas:

  table(count.fields("persistency.csv", sep=","))

--
David.

>
> -M
>
> On Fri, Jul 6, 2012 at 2:36 PM, David Winsemius <[hidden email]
> > wrote:
>
> On Jul 6, 2012, at 1:39 PM, C W wrote:
>
> Quick question, what the memory size in R?
> I converted to CSV, but only 53300 of the 1,000,000 rows were read  
> in.  Did
> R run out of memory?  If so, is there a work around?
>
> You probably have mismatched quotes. Consider using quote="". Also  
> consider doing this:
>
> table(count.fields(file-name)) # with a valid file name
>
> That count.fields function is very useful since it accepts the same  
> arguments as the read.tables functions, with defaults of:
>
>  quote = "\"'", skip = 0, blank.lines.skip = TRUE, comment.char = "#")
>
> --
> David.
>
> Thanks,
> Mike
>
> On Fri, Jul 6, 2012 at 1:24 PM, Duncan Murdoch <[hidden email]
> >wrote:
>
> On 06/07/2012 1:11 PM, C W wrote:
>
> Hi all
> I have a large SAS data set, how do I get it read in R?
>
> The data is too big (about 400,000 rows by 100 columns) to be saved  
> as an
> Excel file.  How should I get it read in R?  Any packages?  I don't  
> seem
> to
> find any.
>
>
> You could write it out in some plain delimited format, e.g. CSV or
> tab-delimited.  Watch out for special characters in strings that  
> confuse R
> when it reads it in (e.g. commas in unquoted CSV strings, quotes  
> within
> strings, etc.)
>
> Duncan Murdoch
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>
> David Winsemius, MD
> West Hartford, CT
>
>

David Winsemius, MD
West Hartford, CT

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

Re: How to import SAS data in R?

tmrsg11
Has anyone read SAS file .sas7bdat into R.  The above suggestions don't
work.
-M
On Fri, Jul 6, 2012 at 3:06 PM, David Winsemius <[hidden email]>wrote:

>
> On Jul 6, 2012, at 2:49 PM, C W wrote:
>
>  Hey, David
>>
>> table(count.fields()) is telling me have 11 columns, but I have way more,
>> more like 30 columns.
>> > table(count.fields("**persistency.csv"))
>>
>>      1      2      3      4      5      6      7      8      9     11
>> 439384  39617  16130  21993  12556   1900    988    713     61      1
>>
>>
> I don't usually put back the list address when responding to a private
> email, but I'm breaking my rule. You should not send private follow-ups for
> threads that start on the list unless there is something that other readers
> might not benefit from seeing.
>
>  If it is a CSV file then you need to tell count.fields to use commas:
>
>  table(count.fields("**persistency.csv", sep=","))
>
> --
> David.
>
>
>> -M
>>
>> On Fri, Jul 6, 2012 at 2:36 PM, David Winsemius <[hidden email]>
>> wrote:
>>
>> On Jul 6, 2012, at 1:39 PM, C W wrote:
>>
>> Quick question, what the memory size in R?
>> I converted to CSV, but only 53300 of the 1,000,000 rows were read in.
>>  Did
>> R run out of memory?  If so, is there a work around?
>>
>> You probably have mismatched quotes. Consider using quote="". Also
>> consider doing this:
>>
>> table(count.fields(file-name)) # with a valid file name
>>
>> That count.fields function is very useful since it accepts the same
>> arguments as the read.tables functions, with defaults of:
>>
>>  quote = "\"'", skip = 0, blank.lines.skip = TRUE, comment.char = "#")
>>
>> --
>> David.
>>
>> Thanks,
>> Mike
>>
>> On Fri, Jul 6, 2012 at 1:24 PM, Duncan Murdoch <[hidden email]>
>> **wrote:
>>
>> On 06/07/2012 1:11 PM, C W wrote:
>>
>> Hi all
>> I have a large SAS data set, how do I get it read in R?
>>
>> The data is too big (about 400,000 rows by 100 columns) to be saved as an
>> Excel file.  How should I get it read in R?  Any packages?  I don't seem
>> to
>> find any.
>>
>>
>> You could write it out in some plain delimited format, e.g. CSV or
>> tab-delimited.  Watch out for special characters in strings that confuse R
>> when it reads it in (e.g. commas in unquoted CSV strings, quotes within
>> strings, etc.)
>>
>> Duncan Murdoch
>>
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________**________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>> David Winsemius, MD
>> West Hartford, CT
>>
>>
>>
> David Winsemius, MD
> West Hartford, CT
>
>

        [[alternative HTML version deleted]]

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

Re: How to import SAS data in R?

Duncan Murdoch-2
On 06/07/2012 3:30 PM, C W wrote:
> Has anyone read SAS file .sas7bdat into R.  The above suggestions don't
> work.

They work if you follow them.

Duncan Murdoch

> -M
> On Fri, Jul 6, 2012 at 3:06 PM, David Winsemius <[hidden email]>wrote:
>
> >
> > On Jul 6, 2012, at 2:49 PM, C W wrote:
> >
> >  Hey, David
> >>
> >> table(count.fields()) is telling me have 11 columns, but I have way more,
> >> more like 30 columns.
> >> > table(count.fields("**persistency.csv"))
> >>
> >>      1      2      3      4      5      6      7      8      9     11
> >> 439384  39617  16130  21993  12556   1900    988    713     61      1
> >>
> >>
> > I don't usually put back the list address when responding to a private
> > email, but I'm breaking my rule. You should not send private follow-ups for
> > threads that start on the list unless there is something that other readers
> > might not benefit from seeing.
> >
> >  If it is a CSV file then you need to tell count.fields to use commas:
> >
> >  table(count.fields("**persistency.csv", sep=","))
> >
> > --
> > David.
> >
> >
> >> -M
> >>
> >> On Fri, Jul 6, 2012 at 2:36 PM, David Winsemius <[hidden email]>
> >> wrote:
> >>
> >> On Jul 6, 2012, at 1:39 PM, C W wrote:
> >>
> >> Quick question, what the memory size in R?
> >> I converted to CSV, but only 53300 of the 1,000,000 rows were read in.
> >>  Did
> >> R run out of memory?  If so, is there a work around?
> >>
> >> You probably have mismatched quotes. Consider using quote="". Also
> >> consider doing this:
> >>
> >> table(count.fields(file-name)) # with a valid file name
> >>
> >> That count.fields function is very useful since it accepts the same
> >> arguments as the read.tables functions, with defaults of:
> >>
> >>  quote = "\"'", skip = 0, blank.lines.skip = TRUE, comment.char = "#")
> >>
> >> --
> >> David.
> >>
> >> Thanks,
> >> Mike
> >>
> >> On Fri, Jul 6, 2012 at 1:24 PM, Duncan Murdoch <[hidden email]>
> >> **wrote:
> >>
> >> On 06/07/2012 1:11 PM, C W wrote:
> >>
> >> Hi all
> >> I have a large SAS data set, how do I get it read in R?
> >>
> >> The data is too big (about 400,000 rows by 100 columns) to be saved as an
> >> Excel file.  How should I get it read in R?  Any packages?  I don't seem
> >> to
> >> find any.
> >>
> >>
> >> You could write it out in some plain delimited format, e.g. CSV or
> >> tab-delimited.  Watch out for special characters in strings that confuse R
> >> when it reads it in (e.g. commas in unquoted CSV strings, quotes within
> >> strings, etc.)
> >>
> >> Duncan Murdoch
> >>
> >>
> >>         [[alternative HTML version deleted]]
> >>
> >> ______________________________**________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> >> PLEASE do read the posting guide http://www.R-project.org/**
> >> posting-guide.html <http://www.R-project.org/posting-guide.html>
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >> David Winsemius, MD
> >> West Hartford, CT
> >>
> >>
> >>
> > David Winsemius, MD
> > West Hartford, CT
> >
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

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

Re: How to import SAS data in R?

David Winsemius
In reply to this post by tmrsg11

On Jul 6, 2012, at 3:30 PM, C W wrote:

> Has anyone read SAS file .sas7bdat into R.  The above suggestions  
> don't work.

help(package=foreign)

And read the Import/Export Manual

--


> -M
> On Fri, Jul 6, 2012 at 3:06 PM, David Winsemius <[hidden email]
> > wrote:
>
> On Jul 6, 2012, at 2:49 PM, C W wrote:
>
> Hey, David
>
> table(count.fields()) is telling me have 11 columns, but I have way  
> more, more like 30 columns.
> > table(count.fields("persistency.csv"))
>
>      1      2      3      4      5      6      7      8      9     11
> 439384  39617  16130  21993  12556   1900    988    713     61      1
>
>
> I don't usually put back the list address when responding to a  
> private email, but I'm breaking my rule. You should not send private  
> follow-ups for threads that start on the list unless there is  
> something that other readers might not benefit from seeing.
>
>  If it is a CSV file then you need to tell count.fields to use commas:
>
>  table(count.fields("persistency.csv", sep=","))
>
> --
> David.
>
>
> -M
>
> On Fri, Jul 6, 2012 at 2:36 PM, David Winsemius <[hidden email]
> > wrote:
>
> On Jul 6, 2012, at 1:39 PM, C W wrote:
>
> Quick question, what the memory size in R?
> I converted to CSV, but only 53300 of the 1,000,000 rows were read  
> in.  Did
> R run out of memory?  If so, is there a work around?
>
> You probably have mismatched quotes. Consider using quote="". Also  
> consider doing this:
>
> table(count.fields(file-name)) # with a valid file name
>
> That count.fields function is very useful since it accepts the same  
> arguments as the read.tables functions, with defaults of:
>
>  quote = "\"'", skip = 0, blank.lines.skip = TRUE, comment.char = "#")
>
> --
> David.
>
> Thanks,
> Mike
>
> On Fri, Jul 6, 2012 at 1:24 PM, Duncan Murdoch <[hidden email]
> >wrote:
>
> On 06/07/2012 1:11 PM, C W wrote:
>
> Hi all
> I have a large SAS data set, how do I get it read in R?
>
> The data is too big (about 400,000 rows by 100 columns) to be saved  
> as an
> Excel file.  How should I get it read in R?  Any packages?  I don't  
> seem
> to
> find any.
>
>
> You could write it out in some plain delimited format, e.g. CSV or
> tab-delimited.  Watch out for special characters in strings that  
> confuse R
> when it reads it in (e.g. commas in unquoted CSV strings, quotes  
> within
> strings, etc.)
>
> Duncan Murdoch
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>
> David Winsemius, MD
> West Hartford, CT
>
>
>
> David Winsemius, MD
> West Hartford, CT
>
>

David Winsemius, MD
West Hartford, CT


        [[alternative HTML version deleted]]

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

Re: How to import SAS data in R?

Daniel Nordlund-4
In reply to this post by tmrsg11
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> On Behalf Of C W
> Sent: Friday, July 06, 2012 12:30 PM
> To: David Winsemius
> Cc: r-help help
> Subject: Re: [R] How to import SAS data in R?
>
> Has anyone read SAS file .sas7bdat into R.  The above suggestions don't
> work.
> -M
> On Fri, Jul 6, 2012 at 3:06 PM, David Winsemius
> <[hidden email]>wrote:
>
> >
> > On Jul 6, 2012, at 2:49 PM, C W wrote:
> >
> >  Hey, David
> >>
> >> table(count.fields()) is telling me have 11 columns, but I have way
> more,
> >> more like 30 columns.
> >> > table(count.fields("**persistency.csv"))
> >>
> >>      1      2      3      4      5      6      7      8      9     11
> >> 439384  39617  16130  21993  12556   1900    988    713     61      1
> >>
> >>
> > I don't usually put back the list address when responding to a private
> > email, but I'm breaking my rule. You should not send private follow-ups
> for
> > threads that start on the list unless there is something that other
> readers
> > might not benefit from seeing.
> >
> >  If it is a CSV file then you need to tell count.fields to use commas:
> >
> >  table(count.fields("**persistency.csv", sep=","))
> >
> > --
> > David.
> >
> >
> >> -M
> >>
> >> On Fri, Jul 6, 2012 at 2:36 PM, David Winsemius
> <[hidden email]>
> >> wrote:
> >>
> >> On Jul 6, 2012, at 1:39 PM, C W wrote:
> >>
> >> Quick question, what the memory size in R?
> >> I converted to CSV, but only 53300 of the 1,000,000 rows were read in.
> >>  Did
> >> R run out of memory?  If so, is there a work around?
> >>
> >> You probably have mismatched quotes. Consider using quote="". Also
> >> consider doing this:
> >>
> >> table(count.fields(file-name)) # with a valid file name
> >>
> >> That count.fields function is very useful since it accepts the same
> >> arguments as the read.tables functions, with defaults of:
> >>
> >>  quote = "\"'", skip = 0, blank.lines.skip = TRUE, comment.char = "#")
> >>
> >> --
> >> David.
> >>
> >> Thanks,
> >> Mike
> >>
> >> On Fri, Jul 6, 2012 at 1:24 PM, Duncan Murdoch
> <[hidden email]>
> >> **wrote:
> >>
> >> On 06/07/2012 1:11 PM, C W wrote:
> >>
> >> Hi all
> >> I have a large SAS data set, how do I get it read in R?
> >>
> >> The data is too big (about 400,000 rows by 100 columns) to be saved as
> an
> >> Excel file.  How should I get it read in R?  Any packages?  I don't
> seem
> >> to
> >> find any.
> >>
> >>
> >> You could write it out in some plain delimited format, e.g. CSV or
> >> tab-delimited.  Watch out for special characters in strings that
> confuse R
> >> when it reads it in (e.g. commas in unquoted CSV strings, quotes within
> >> strings, etc.)
> >>
> >> Duncan Murdoch
> >>
> >>
> >>         [[alternative HTML version deleted]]
> >>
> >> ______________________________**________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/**listinfo/r-
> help<https://stat.ethz.ch/mailman/listinfo/r-help>
> >> PLEASE do read the posting guide http://www.R-project.org/**
> >> posting-guide.html <http://www.R-project.org/posting-guide.html>
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >> David Winsemius, MD
> >> West Hartford, CT
> >>
> >>
> >>
> > David Winsemius, MD
> > West Hartford, CT
> >
> >
>

As has been pointed out there are many ways to get SAS data into R.  Some are easier than others, depending on what the structure of the data is, and whether or not you have access to SAS.  The sas7bdat package works fine for reading many (but not all) SAS datasets with the extension of .sas7bdat

Do you have access to SAS or do you just have the SAS dataset?  Is this a one time thing, or are you going to be moving data back and forth between SAS and R a lot?  I have found that the easiest method for me to move data back and forth between SAS and R is to use the Stata file format as a common format.  Both SAS (v9.2 with SAS ACCESS to PC File Formats) and R read and write Stata format data files just fine.  Again if you have SAS, the sas.get function in the Hmisc package is very useful.  

If you don't have SAS, then you will need to follow the advice that has already been give (and follow it carefully).

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA
 

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

Re: How to import SAS data in R?

kenkl
In reply to this post by tmrsg11
In addition to the helpful guidance suggested already, you might investigate the sas7bdat package, by Matt Shotwell.

I described it here: http://sas-and-r.blogspot.com/2011/07/really-useful-r-package-sas7bdat.html

Ken
Loading...