Wednesday, May 22, 2013

Some R Code Using SAScii

For example, I want use Adult Demographic File from NHANES III. To import it using SAScii

library(SAScii)
SAScode <- "ftp://ftp.cdc.gov/pub/Health_Statistics/NCHS/nhanes/nhanes3/1A/adult.sas"
ftpdata <-"ftp://ftp.cdc.gov/pub/Health_Statistics/NCHS/nhanes/nhanes3/1A/adult.dat"
data <- read.SAScii(ftpdata, SAScode, beginline=5)

Because the line with INPUT in the SAS code file begins at line 5, I gave the option begineline=5. Of course, it assumes that you have downloaded and installed the package ‘SAScii’. Now you can save this file in any desirable format or use it for further downstream analysis. It does take quite sometime, longer than what it would take using SAS, but it does produce desired output.

No comments: