<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to change the output format of a few columns in ods excel? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766519#M25302</link>
    <description>&lt;P&gt;To give you the full background, initially the process involved ods html and we were creating .xls file that were not actually Excel, but MS Excel was able to open them and we had to do a &lt;STRONG&gt;Save As Excel&lt;/STRONG&gt;.&amp;nbsp; This caused a few problems one being the size of those html files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We were actually using PROC REPORT with ods html:&lt;/P&gt;&lt;PRE&gt;proc report data = output_xlsd&amp;amp;j;
	column _all_;
	title;
	define EngineSize	 / display style(column)={htmlstyle="mso-number-format:0\.00"};
run;&lt;/PRE&gt;&lt;P&gt;This would only convert the EngineSize to numeric type while all the others were text by default in the output file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So now I am planning to change that piece of code to use ods excel to create true excel files. However the problem is that with ods excel it does not change them to text/string. And I believe I'd have to explicitly define the formats for all the variables(which would be 400). I am looking for a way around this.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Sep 2021 06:25:40 GMT</pubDate>
    <dc:creator>vgoel</dc:creator>
    <dc:date>2021-09-08T06:25:40Z</dc:date>
    <item>
      <title>How to change the output format of a few columns in ods excel?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766473#M25299</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I am using this piece of code on the &lt;STRONG&gt;sashelp.cars&lt;/STRONG&gt; dataset:&lt;/P&gt;&lt;PRE&gt;options symbolgen;

data output_x;
	set sashelp.cars;
run;

/*define max no. rows in the output*/
%let num_of_rows=150;
%let n=&amp;amp;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((&amp;amp;nobs / &amp;amp;n)+1)));

%macro test;
	/*loop through one part at a time*/
	%do j=1 %to &amp;amp;tot;
		%let fobs=%eval((&amp;amp;num_of_rows*%eval(&amp;amp;j-1))+1);
		%let lobs=%eval(&amp;amp;num_of_rows*&amp;amp;j);

		data output_xlsd&amp;amp;j;
			set output_x(FIRSTOBS=&amp;amp;fobs. OBS=&amp;amp;lobs.);
		run;

		ods excel file="/location/&amp;amp;j._of_&amp;amp;tot..xlsx";

		proc print data=output_xlsd&amp;amp;j style(data)={tagattr='type:text'};
		run;

		ods excel close;
	%end;
%mend;

%test;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve this?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 19:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766473#M25299</guid>
      <dc:creator>vgoel</dc:creator>
      <dc:date>2021-09-07T19:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the output format of a few columns in ods excel?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766479#M25300</link>
      <description>&lt;P&gt;You can use PROC TRANSPOSE to convert numeric variables to character using the associated formats.&amp;nbsp; This process can preserve variable order and variable&lt;/P&gt;
&lt;P&gt;labels.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cars;
	set sashelp.cars;
   _obs_+1;
   run;
proc transpose data=cars out=cars1;
   by _obs_;
   var make--length;
   format enginesize 8.2;
   run;
data cars2;
   set cars1;
   col1 = left(col1);
   run;
proc transpose data=cars2 out=charcars(drop=_name_ _obs_);
   by _obs_;
   var col1;
   id _name_;
   idlabel _label_;
   run;
proc contents varnum;
proc print;
   run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-09-07 153101.png" style="width: 879px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63369i8D117EA062657A2F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-09-07 153101.png" alt="Screenshot 2021-09-07 153101.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-09-07 153203.png" style="width: 267px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63370i2182DA6AF739604C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-09-07 153203.png" alt="Screenshot 2021-09-07 153203.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 20:35:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766479#M25300</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2021-09-07T20:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the output format of a few columns in ods excel?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766498#M25301</link>
      <description>I think you may need to use PROC REPORT and to define each column individually....definitely using a macro if you have 400 though you may be able to use a similar data approach as with PROC PRINT and then only override the few columns you need.</description>
      <pubDate>Tue, 07 Sep 2021 23:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766498#M25301</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-07T23:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the output format of a few columns in ods excel?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766519#M25302</link>
      <description>&lt;P&gt;To give you the full background, initially the process involved ods html and we were creating .xls file that were not actually Excel, but MS Excel was able to open them and we had to do a &lt;STRONG&gt;Save As Excel&lt;/STRONG&gt;.&amp;nbsp; This caused a few problems one being the size of those html files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We were actually using PROC REPORT with ods html:&lt;/P&gt;&lt;PRE&gt;proc report data = output_xlsd&amp;amp;j;
	column _all_;
	title;
	define EngineSize	 / display style(column)={htmlstyle="mso-number-format:0\.00"};
run;&lt;/PRE&gt;&lt;P&gt;This would only convert the EngineSize to numeric type while all the others were text by default in the output file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So now I am planning to change that piece of code to use ods excel to create true excel files. However the problem is that with ods excel it does not change them to text/string. And I believe I'd have to explicitly define the formats for all the variables(which would be 400). I am looking for a way around this.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 06:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766519#M25302</guid>
      <dc:creator>vgoel</dc:creator>
      <dc:date>2021-09-08T06:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the output format of a few columns in ods excel?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766615#M25303</link>
      <description>Have you tried this yet or are you assuming you're having these issuees?</description>
      <pubDate>Wed, 08 Sep 2021 15:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-change-the-output-format-of-a-few-columns-in-ods-excel/m-p/766615#M25303</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-08T15:21:50Z</dc:date>
    </item>
  </channel>
</rss>

