Blog 2:Importing and Exporting excel File in SAS

Welcome back to blog 2. Today's area of discussion is to import and export the excel file.

Use proc import to convert the  spreadsheet drugtest. Use proc print to list down the observations in this dataset





Code:
The main aim of this programme for import and export the excel */
/*Question1*/
1)proc import
2)out= work.drugtest
3)datafile = 'C:\Users\Elcot\Desktop\SAS\neha sas cody book\Practice set 4\drugtest.xls'
4)dbms=xls
5)replace;
6)sheet = "sheet1";
7)getnames = yes;
8)run;
9)proc print data = drugtest;
10)run;

Solution/Explanation:
1) proc import is the procedure to import the file
2) out states the destination where the file would be saved here it is in work library and the data set is named drugtest.
3)datafile states the path where the file is saved which is to be imported
4) dbms refers to the format of the file
5) replace overwrites an already existing data set
6)sheet refers to the sheet name
7)getnames refers to the columns names to be retained
Last 2 statements are the procedure to print the dataset named drugtest.


Q2)


Code:
data isl;
input team & $20. played:2. won:2. draw:2. loss:2. GF:2. GA:2. GD:2. Points:2.;
datalines;
Chennaiyin FC  14 6 5 3 24 20 4 23
FC Goa  14 6 4 4 21 12 9 22
Atletico de Kolkata  14 4 5 5 16 13 3 19
Kerala Blasters FC  14 5 4 5 9 11 -2 19
Delhi Dynamos FC  14 4 6 4 16 14 2 18
FC Pune City  14 4 4 6 12 17 -5 16
Mumbai City FC  14 4 6 6 12 21 -9 16
NorthEast United FC  14 3 6 5 11 13 -2 15
;
run;
proc print data=isl;
run;
For exporting the data follow the simple steps:

1) From file select the export statement
2) Mention the library and the member name
3) select the type of file you want to export in this excel file
4) Address where you want to place the file
5)enter the table name

The file is exported




There are different ways to import and export the files. Here I have used a mixure proc import in 1st case and manual export in the second case. You can use Proc export in the second case as well

 
 

Comments

Popular posts from this blog

Kabaddi Match: Lets meet at the arena!! Aa jao Dam Dikhane!!!

Text Analytics Using R - Part A: Extraction of reviews of galaxy s4 product reviews in flipkart

Replace your Social Media with the New Age Social Media: Fitness with Motivation