Quickguide: How to import external data into SAS

Update: Quick Code.

PROC IMPORT OUT = <libname>.<dataset name> DATAFILE= “<Excel file path>”

            DBMS=EXCEL REPLACE;

 GETNAMES=YES;

RUN;

Example:

PROC IMPORT OUT= WORK.company DATAFILE= “C:\Users\Parth\Documents\SAS\SASexamples\Company_info.xlsx”

DBMS=EXCEL REPLACE;

GETNAMES=YES;

RUN;

———

Original Blog Begins Here:

 

Here is the code to get external data (csv, xls, txt) into your SAS environment.

The basic objective is to get your *.csv or *.xls file converted to *.sas7bdat format (which is the default extension for SAS EnterpriseMiner)

Open SAS (not EnterpriseMiner).

After opening SAS, go to the Editor and type the following line of codes:

IMPORTANT NOTE: After writing each block of codes, select the written code and click the ‘run’ button.

NOTE: The terms in Bold should be colored (mostly blue).

#We will first create an empty data set called ‘main’.

data main;

run;

—-

#Tell SAS about the Contents in our data set ‘main’ and print it.

proc contents data=main;
run;

proc print data=main;
run;

—-

#Now Import your excel/csv file

proc import datafile='<<Enter the path to your file>>’

out=main replace dbms=csv;
run;

example for procedure: proc import datafile=’C:\Downloads\MIS6324BI\Titanic Data\train.csv’

Note: ‘out=main’ because the data set we created is named as ‘main’.

Note: If the file you want to import is Excel, type- “dbms=excel

—-

#Create a new library

libname home “<<Path of your wish to the library>>”;

example: libname home “C:\Users\parth\Documents\My SAS Files\”

—-

#Run the following codes in order to get the imported file into your ‘main’ data set. And then to get your newly created ‘main’ data into the above created library.

data sas_format; set home.main;
run;

data home.sas_format; set work.main;
run;

—-

The resulting SAS format files will be in the library path you have given to SAS. In this case- ‘C:\Users\parth\Documents\My SAS Files\’

Please do comment on this post if you find any problem following the steps to import data into SAS.

Social media and customer dialog management at Starbucks

Here is presentation created for one of the courses I have taken this semester: Business Intelligence under Professor Zhiqiang Zheng.

It introduces how 3-M Framework (Megaphone, Magnet and Monitor) helps businesses create Social Media Campaigns/Strategies and focuses mainly on how Starbucks does the Customer Dialog Management through Social Media.

This slideshow requires JavaScript.

Would love to have your response on this one, share what you think about the 3-M framework! :)

%d bloggers like this: