a simple technique for outputting a data set to a csv file

1
A Simple Technique for Outputting a Data Set to a CSV File If you need to create a comma separated file from a SAS data set, then a quick and easy technique that avoids the need to insert commas between each variable is as follows: Program: filename classcsv 'c:\class.csv'; data _null_; file classcsv; set sashelp.class; put (_all_)(','); run; To output specific variables, replace '_ALL_' with the required variable names separated by spaces. Adding the MOD option to the either the filename or file statement appends to the output file rather than overwriting existing values. Use filename classcsv 'c:\class.csv' mod; or file classcsv mod;

Upload: naraine-kanth

Post on 14-Dec-2015

214 views

Category:

Documents


0 download

DESCRIPTION

sas

TRANSCRIPT

Page 1: A Simple Technique for Outputting a Data Set to a CSV File

A Simple Technique for Outputting a Data Set to a CSV File

If you need to create a comma separated file from a SAS data set, then a quick and easy

technique that avoids the need to insert commas between each variable is as follows: 

Program:filename classcsv 'c:\class.csv';

 

data _null_;

  file classcsv;

  set sashelp.class;

  put (_all_)(',');

run;

 

To output specific variables, replace '_ALL_' with the required variable names separated by

spaces. 

Adding the MOD option to the either the filename or file statement appends to the output file

rather than overwriting existing values. Usefilename classcsv 'c:\class.csv' mod;

 

orfile classcsv mod;