Base SAS -Exporting Data out of SAS

How to export a SAS dataset out in your disk

Unlike Import, Export in  SAS is not that complicated to learn. We strongly recommend to use Procedure for exporting; it would suffice in 99.99% situations.

Feeling impatient to learn it ... all right here it is.


For learning Exporting let's create a data.I am using one of the example from Import Article.

Data claim_data;
Input Gender $ Name $ Claim_amount ;
Cards;
Male Naveen 10000
Male Mahesh 15000
Male Amit 7500
Female Neeta 18000
Female Geeta 12000
;
Run;

Run the above code in SAS and you will get claim_data dataset in work Library.

Now suppose post working on this data, you want to export it ... use Proc export for it.

Proc Export data = claim_data
outfile = "Location\claim_data.csv"
dbms = csv replace;

run;

 The above code would give you claim_data.csv file at location that you specify. Please do use replace option, as if you some changes in data, and export the data again "replace" option would enable the replacement of file. If yu don't use this option and already file is there at location, export would fail.

You can use other options in Proc Export such as :

For customized delimiter

Proc Export data = claim_data
outfile = "Location\claim_data_1.txt"
dbms = dlm replace;
delimiter = ":";
run;

For exporting into excel

Proc Export data = claim_data
outfile = "D:\claim_data_1.xlsx"
dbmsxlsx replace;
sheet = "Name of sheet";
run;

or in case of old excel format

Proc Export data = claim_data
outfile = "D:\claim_data_1.xls"
dbms =  excel replace;
sheet = "Name of sheet";
run;

.... You can try variations into it ... as such that's more than sufficient to learn about exporting in SAS.


Enjoy reading our other articles and stay tuned with ...

Kindly do provide your feedback in the 'Comments' Section and share as much as possible.

No comments:

Post a Comment

Do provide us your feedback, it would help us serve your better.