Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in R Programming by (50.2k points)

In my RStudio and data that came in a.CSV file. There is variable information including data element label, type, number of digits, etc. that have been provided in a.SAS as well as a .do file. I understand these correspond to either SAS or STATA. These are all (.csv, .sas, .do) in a single folder on my desktop.

The below code of for importing the dataset:

library(readr)

NRD_2017_Hospital <- read_csv("My Documents/Data/2017/2017_School.CSV")

View(2017_School)

SASIN <- "C:/Users/Quix/Documents/My Documents/Data/2017/2017_School.SAS"

Getting the headers and other variable information isn't working. I've tried the library(SAScii) and it comes up with errors: 

data1<- read.SAScii(2017_School, SASIN)

The error:

Error in if (as.numeric(x[j, "start"]) > as.numeric(x[j - 1, "end"]) +  : 

missing value where TRUE/FALSE needed

In addition: Warning messages:

1: In parse.SAScii(sas_ri, beginline, lrecl) : NAs introduced by coercion

2: In parse.SAScii(sas_ri, beginline, lrecl) : NAs introduced by coercion

3: In parse.SAScii(sas_ri, beginline, lrecl) : NAs introduced by coercion

4: In parse.SAScii(sas_ri, beginline, lrecl) : NAs introduced by coercion

5: In parse.SAScii(sas_ri, beginline, lrecl) : NAs introduced by coercion

How to get the data and headers to load together in R?

1 Answer

0 votes
by (107k points)

Without having access to the file, it is difficult for us to replicate, but haven::read_sas() has worked for most SAS files I've had to use:

library(haven)

data1 <- read_sas("C:/Users/Quix/Documents/My Documents/Data/2017/2017_School.SAS")

If you are a beginner and want to know more about R, then do refer to the R programming tutorial

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...