39%macro mp_csv2ds(inref=0,outds=0,baseds=0,view=NO);
41%mp_abort(iftrue=( &inref=0 )
43 ,msg=%str(the INREF variable must be provided)
45%mp_abort(iftrue=( %superq(outds)=0 )
47 ,msg=%str(the OUTDS variable must be provided)
49%mp_abort(iftrue=( &baseds=0 )
51 ,msg=%str(the BASEDS variable must be provided)
53%mp_abort(iftrue=( %mf_existds(&baseds)=0 )
55 ,msg=%str(the BASEDS dataset (&baseds) needs to be assigned, and to exist)
59%local hasheader; %let hasheader=0;
62 call symputx(
'hasheader',1,
'l');
68%mp_abort(iftrue=( &hasheader=0 )
70 ,msg=%str(No header row in &inref)
78 do i=1 to countc(_infile_,
',')+1;
79 name=upcase(scan(_infile_,i,
','));
84%local csv_vars;%let csv_vars=&syslast;
87proc contents noprint data=&baseds
88 out=_data_ (keep=name type length format: informat);
90%local base_vars; %let base_vars=&syslast;
92proc sql undo_policy=none;
93create table &csv_vars as
102 left join &base_vars b
103 on a.name=upcase(b.name)
107%local instat dropvars;
109 set &syslast end=last;
110 length in dropvars $32767;
112 if missing(type) then do;
114 dropvars=catx(' ',dropvars,name);
116 else if missing(informat) then do;
117 if type=1 then informat='best.';
118 else informat=cats('$',length,'.');
120 else informat=cats(informat,'.');
121 in=catx(' ',in,name,':',informat);
123 call symputx('instat',in,'l');
124 call symputx('dropvars',dropvars,'l');
130 %if %upcase(&view)=YES %then %do;
134 infile &inref dsd firstobs=2;
136 %if %length(&dropvars)>0 %then %do;