Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mp_csv2ds.sas File Reference

Efficient import of arbitrary CSV using a dataset as template. More...

Go to the source code of this file.

Detailed Description

Used to import relevant columns from a large CSV using a dataset to provide the types and lengths. Assumes that a header row is provided, and datarows start on line 2. Extra columns in both the CSV and base dataset are ignored.

Usage:

filename mycsv temp;
data _null_;
  file mycsv;
  put 'name,age,nickname';
  put 'John,48,Jonny';
  put 'Jennifer,23,Jen';
run;

%mp_csv2ds(inref=mycsv,outds=myds,baseds=sashelp.class)
Parameters
inref=fileref to the CSV
outds=output ds (lib.ds format)
view=Set to YES or NO to determine whether the output should be a view or not. Default is NO (not a view).
baseds=Template dataset on which to create the input statement. Is used to determine types, lengths, and any informats.
Version
9.2
Author
Allan Bowe

Dependencies

Definition in file mp_csv2ds.sas.