Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 12-02-2018 03:54 AM
(1151 views)

Hi,

I am new to R and have been trying out how to integrate R codes in SAS.

In a single SAS program, I have some SAS codes followed by R codes.

Can I call on the SAS datasets (mydataset1 mydataset2) without doing the ExportDataSetToR step?

The reason why I'm asking is there seemed to be some limit on the length of the variables in the dataset when doing the ExportDataSetToR step.

```
data mydataset1;
set mylibrary.mydataset1;
run;
```

data mydataset2;

set mylibrary.mydataset2;

run;

proc iml;
run ExportDataSetToR("mydataset1", "rdataset1");

run ExportDataSetToR("mydataset2", "rdataset2");
submit / R;
#_______Begin of R code_________________
total <- merge(data mydataset1, data mydataset2, by="ID")
#_______End of R code_________________
endsubmit;

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The ExportDataSetToR subroutine creates an R data frame from data in a SAS data set. It also converts some variable representations (dates, times, missing values,...) into the analogous R representations.

To answer your question, you are not required to use the ExportDataSetToR subroutine, but I think it is the most reliable and efficient way to form an R data frame from SAS data. If you prefer to import the data some other way (an R package, converting to CSV,...) then you can do so. However, I can't think of an example in which I would recommend that approach.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks. I am having issues with ExportDataSetToR as the length of one of the string variable is very long (address).

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

If you provide details and an example, someone might be able to help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. **Registration is now open through August 30th**. Visit the SAS Hackathon homepage.

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.