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
[in]inref=(0) Fileref to the CSV
[out]outds=(0) Output ds (lib.ds format)
[in]view=(NO) Set to YES or NO to determine whether the output should be a view or not. Default is NO (not a view).
[in]baseds=(0) Template dataset on which to create the input statement. Is used to determine types, lengths, and any informats.
Version
9.2
Author
Allan Bowe

SAS Macros

Definition in file mp_csv2ds.sas.