Warning: Creating default object from empty value in /home3/science4/public_html/rconvert.com/Convert_SAS_To_R_Statistical_Data/wp-content/themes/optimize/functions/admin-hooks.php on line 160

Below are methods for importing a csv file into both R and SAS.  The csv file to import is named “file.csv” and the data, once imported, is called tbl.  In SAS, there are two main approaches to importing a csv file.  The two methods are proc import and a data step.

R

tbl <- read.csv("C:/data/file.csv")

SAS

/* PROC Import Approach */

proc import datafile="C:\data\file.csv"
    out=tbl
    dbms=csv
    replace;
    getnames=yes;
run;

/* Data Step Approach */

data tbl;
    infile "C:\data\file.csv"
    delimiter=',';
    input var1 var2 ... varn;
run;

 

Leave a Reply


7 − = six