Hi,
This macro outputs XPT files with file names in 'uppercase'. Can we change this and give the output filenames in 'lowercase'?
You can use any sas dataset from your directory. Please change the path (input path and output path) or you can use sashelp library too.
%macro xpt;
libname raw_sets " input Path ";
proc contents data=raw_sets._all_ out=datasets noprint;
run;
proc sql noprint;
select distinct(MEMNAME),count(distinct(MEMNAME)) into:alldata1-,:datan
from datasets;
quit;
/*%put &alldata1,&datan;*/
%do i=1 %to &datan;
libname raw_xpt xport "output path\&&alldata&i...xpt";
proc copy in=raw_sets out=Raw_xpt memtype=data;
select &&alldata&i.;
run;
%end;
%mend xpt;
%xpt;
Thank you
Why not just use the LOWCASE() function?
Fix the SQL step.
proc sql noprint;
select distinct lowcase(MEMNAME)
into :alldata1-
from datasets
;
%let datan=&sqlobs;
quit;
You could also get rid of the macro (or at least the macro logic and macro variables).
libname raw_sets " input Path ";
proc contents data=raw_sets._all_ out=datasets noprint;
run;
data _null_;
set datasets;
by memname;
if first.memname;
call execute(catx(' '
, 'libname raw_xpt xport'
, quote(cats('output path/', lowcase(memname), '.xpt'),"'")
, ';'
, 'proc copy in=raw_sets out=raw_xpt mt=data;'
, 'select', memname, ';'
, 'run;'
));
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: