Giter VIP home page Giter VIP logo

sascii's People

Contributors

ajdamico avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sascii's Issues

Reading in NHIS survey data with read.SAScii

Hi, I have a question about one of your examples in the documentation for read.SAScii.

Here's the verbatim example:

NHIS.11.samadult.SAS.read.in.instructions <-
"ftp://ftp.cdc.gov/pub/Health_Statistics/NCHS/Program_Code/NHIS/2011/SAMADULT.sas"
NHIS.11.samadult.file.location <-
"ftp://ftp.cdc.gov/pub/Health_Statistics/NCHS/Datasets/NHIS/2011/samadult.zip"

store the NHIS file as an R data frame!

NHIS.11.samadult.df <-
read.SAScii (
NHIS.11.samadult.file.location ,
NHIS.11.samadult.SAS.read.in.instructions ,
zipped = T, )

or store the NHIS SAS import instructions for use in a

read.fwf function call outside of the read.SAScii function

NHIS.11.samadult.sas <- parse.SAScii( NHIS.11.samadult.SAS.read.in.instructions )

save the data frame now for instantaneous loading later

save( NHIS.11.samadult.df , file = "NHIS.11.samadult.data.rda" )

I am trying to do the same with the 2010 version of the survey. However, with both this 2011 file and the 2010 file I get the error Error in toupper(SASinput) : invalid multibyte string 533 with the read.SAScii call. What can you make of it? Thanks!

Installation Issues

Using the following code, I get the following error.
Any updates on code for previous versions?
Thanks


{install.packages("SAScii", dependencies = TRUE) }
Warning in install.packages :
  package ‘SAScii’ is not available for this version of R

toupper(SASinput) error in parse.SAScii

Hi, your package has been a lifesaver and significantly streamlined my code. However, I encountered the following error when running the read.SAScii() function: Error in toupper(SASinput) : invalid multibyte string 1234.

Looking through the source code, I narrowed the error down to the toupper() function call on line 10 and/or line 27 of the parse.SAScii() helper function. I figure it must have something to do with the text encoding in the SAS import instructions I was supplied with, which toupper() fails to handle.

I found a fix though, and that was to change toupper() from base R to stri_trans_toupper() from the stringi package. Whatever the issue was with toupper(), stri_trans_toupper() overcame the issue.

I am running:
R version 4.2.0 (2022-04-22) -- "Vigorous Calisthenics"
Platform: x86_64-apple-darwin17.0 (64-bit)

Code:

# Load package
library(SAScii)

# File/instruction locations
instructions_2008 <- 'ftp://ftp.cdc.gov/pub/Health_Statistics/NCHS/Program_Code/NHIS/2008/SAMADULT.sas'
file_location_2008 <- 'ftp://ftp.cdc.gov/pub/Health_Statistics/NCHS/Datasets/NHIS/2008/samadult.zip'

# Import data
data_2008 <- read.SAScii(fn = file_location_2008,
+                        sas_ri = instructions_2008,
+                        zipped = TRUE)

Error in toupper(SASinput) : invalid multibyte string 1234

Add support for different file encodings

The encoding of a SAS input file may be different from the file system encoding. Thus, trying parse.SAScii() in a system (e.g. Linux and, I guess, Mac OS X) with UTF-8 for file encoding will fail with an input file encoded in e.g. ISO-8859-1. This could be remedied by adding a "encoding" parameter in parse.SAScii() (and maybe in read.SAScii() as well), and passing this parameter to the readLines() call.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.