Hi All,
I was wondering is there a way to proc export a data if the data set name = this (as a pipe delimited txt file) else export as a CSV.
thank you!
An easy way is to set a default parameter on a macro then no conditional logic is required:
%macro MyExport (dataset =
,filename =
,DLM = ','
);
proc export data = &dataset
file = "\MyFolder\&filename"
DLM = &DLM
;
run;
%mend MyExport;
%MyExport (dataset = MyCSV, filename = \Myfolder\MyCSV.csv);
%MyExport (dataset = MyPipe, filename = \Myfolder\MyPipe.csv, DLM = '|');
proc export
data=&ds.
dbms=dlm
file="&outfile."
;
delimiter =
%if &ds. = A
%then %do;
","
%end;
%else %do;
"|"
%end;
;
run;
Hi Kurt,
Can I also ask is there a way to output the file in a txt file if its’s pipe delimited and csv if it’s in comma in that same piece of codes you provided below?
thank you,
kelvin.
Clearly define
@Coding4you - Look at the macro code I posted.
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: