Hi, I am generating some excel files out of a dataset and I want all the columns in the output excel to be of string/text type with a few exceptions for which I want to decide the format. Also I want to preserve the order of the columns in the dataset. Currently I am using this piece of code on the sashelp.cars dataset: options symbolgen;
data output_x;
set sashelp.cars;
run;
/*define max no. rows in the output*/
%let num_of_rows=150;
%let n=&num_of_rows;
proc sql noprint;
select count(*) into: nobs from output_x;
quit;
/*define the no. of parts the files needs to divided in*/
%let tot=%sysfunc(ceil(%eval((&nobs / &n)+1)));
%macro test;
/*loop through one part at a time*/
%do j=1 %to &tot;
%let fobs=%eval((&num_of_rows*%eval(&j-1))+1);
%let lobs=%eval(&num_of_rows*&j);
data output_xlsd&j;
set output_x(FIRSTOBS=&fobs. OBS=&lobs.);
run;
ods excel file="/location/&j._of_&tot..xlsx";
proc print data=output_xlsd&j style(data)={tagattr='type:text'};
run;
ods excel close;
%end;
%mend;
%test; This converts all the columns to text. But I'd want to give some of the columns a number format, for instance EngineSize should be a number with 2 decimal places; rest all as text/string. In real scenario I would have 30 columns which I want to give a number format some whole numbers some with two decimal places. And the rest (about 400) to be as text/string in the excel output. How can I achieve this?
... View more