* 출처 : http://cafe.daum.net/statsas/3F8j/312
*****************************************************;
* SAS에서 R 패키지의 RData 형식으로 데이터 내보내기;
* Transfer from a SAS Source to an R Destination;
* http://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_r_sect006.htm;
*****************************************************;
PROC IML;
*** IMPORT TRAINING DATA FROM SAS;
RUN ExportDataSetToR("SASHELP.CLASS","CLASS");
submit / R;
## 작업 경로 위치 지정(SETWorkingDirectory 약어)
setwd("C:/work/SAS/IML")
## 작업 경로 확인(GETWorkingDirectory 약어)
getwd()
## 지정한 객체를 RData형식으로 저장
save(CLASS, file="C:/work/SAS/IML/CLASS.RData")
endsubmit;
quit;
* R 패키지에서 class 데이터 로드;
/*
load(file="C:/work/SAS/IML/CLASS.RData")
*/
*****************************************************;
* R 패키지의 RData 형식의 데이터를 SAS로 읽어오기;
* Transfer from an R Source to a SAS Destination;
* http://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_r_sect007.htm;
*****************************************************;
PROC IML;
submit / R;
## 작업 경로 위치 지정(SETWorkingDirectory 약어)
setwd("C:/work/SAS/IML")
## 작업 경로 확인(GETWorkingDirectory 약어)
getwd()
## 외부에 저장되어 있는 RData 형식의 파일에서 R 객체를 읽어서 메모리 로딩
load(file="C:/work/SAS/IML/CLASS.RData")
endsubmit;
*** IMPORT SCORED COLUMNS INTO SAS;
run ImportDataSetFromR("work.class", "CLASS");
quit;
* 참고 : [PROC IML과 R 패키지] SAS의 PROC IML에서 R 패키지를 사용하여서 데이터 처리 후 결과 값 반환 받기
* 출처 : http://cafe.daum.net/statsas/3F8j/309
*****************************************************;
* 참고 : Import data to R from SAS, SPSS and Stata with Haven (R-bloggers)
* 출처 : https://www.r-bloggers.com/import-data-to-r-from-sas-spss-and-stata-with-haven/
* R의 haven 패키지 : SAS, SPSS, Stata 형식의 데이터를 읽고 쓸 수 있다.
*****************************************************;
# SAS
write_sas(mtcars, "mtcars.sas7bdat")
read_sas("mtcars.sas7bdat")
# Stata
write_dta(mtcars, "mtcars.dta")
read_dta("mtcars.dta")
# SPSS
write_sav(mtcars, "mtcars.sav")
read_sav("mtcars.sav")
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.