Import and Export of dataset using SAS and R

Import and Export of dataset using SAS and R
 

For an analyst, data is a primary raw material, which is used to draw conclusions and inferences for taking business decisions. Raw data is of less help to draw conclusions and inferences. Hence, we need to put the data into any statistical analysis software to slice and dice to bring inference for better decision making. In this post, we will discuss about the steps to import and export of a dataset using SAS and R.

 

Also read: How to Code Colour Values Within SAS Enterprise Guide

 

There are different methods to do import and export of a dataset using SAS and R. The methods can differ as per the file format you are importing and exporting using SAS.

Import a dataset using SAS:

 

Proc import datafile = “F:\SASPractise\Data\Files\class.csv” out = class dbms = csv replace; run;

Proc import datafile = “F:\SASPractise\Data\Files\class.csv” out = class1 dbms = tab replace;

run;

Proc import datafile = “F:\SASPractise\Data\Files\class.txt” out = class2 dbms = dlm replace;

run;

Proc import datafile = “F:\SASPractise\Data\Files\classdup.xls” out = classdup dbms = xls replace;

Sheet = “Sheet1″;

run;

The PROCEDURE IMPORT syntax has three major components to describe,

DATAFILE – specifies the complete path and filename of the input PC file

OUT – identifies the output SAS dataset with either a one or two level SAS name. You can either give a permanent or temporary library name for your reference

DBMS – specifies the type of data to import into SAS

When you import a dataset, you can see the below logs to confirm that the dataset was successfully created.

Class was successfully created.

PROCEDURE IMPORT used.

Export a dataset using SAS:

Proc export data = class.exp1 outfile = “F:\SASPractise\Data\Files\exp1.xls” dbms = tab replace;

run;

Proc export data = class.exp2 outfile = “F:\SASPractise\Data\Files\exp2.csv” dbms = csv replace;

run;

Proc export data = class.exp3 outfile = “F:\SASPractise\Data\Files\exp3.txt” dbms = dlm replace;

delimiter = “,”;

run;

 

Import a dataset using R:

There are multiple ways to import a dataset in R. We will begin with the simplest method in R to import a dataset.

file.choose() method

Example1<-file.choose()

You will be prompted a window, you can simply select the csv, xls, txt file format to import the dataset. It is as simple as that.

Using read.csv () method

Example2 <- read.csv(“c:\\users\desktop\pollution.csv”)

View(Example2)

Export a dataset using R

write.csv() method

write.csv(Example2, “c:\\users\desktop\example2.csv”)

 

Getting the data into any statistical analysis software is one primary step that you take before doing analysis on the data. Moving in and out of data from one system to another will give an analyst the flexibility to use the best algorithms and techniques available in the SAS, R and so on. Once you get the data into any statistical analysis software, you can begin the process of data manipulation and data analysis to draw conclusions and inference from the data with the techniques available in the software system.

 
6
 

Want to make a career in SAS Predictive Modelling? Reach us at DexLab Analytics, as we are the ones who provide credit risk analysis course in Noida for aspiring candidates.

 

Interested in a career in Data Analyst?

To learn more about Machine Learning Using Python and Spark – click here.
To learn more about Data Analyst with Advanced excel course – click here.
To learn more about Data Analyst with SAS Course – click here.
To learn more about Data Analyst with R Course – click here.
To learn more about Big Data Course – click here.

August 12, 2015 5:17 pm Published by , , , , , , ,

, , , , , , , , , ,

Comments are closed here.

...

Call us to know more

×