<?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: Transpose Requires Conversion of transposed variable to text but need to export to Excel as numb in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transpose-Requires-Conversion-of-transposed-variable-to-text-but/m-p/973844#M377753</link>
    <description>&lt;P&gt;can you explain what you want to create it more detail?&amp;nbsp; It would help if you showed an example input dataset and the output you want from it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also explain the reasons for any restrictions. For example why does it matter if the column headers in the EXCEL file are character strings instead of numbers?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note if you are using the YEAR value as the indication of what variable to transpose into then you probably do NOT need to use PROC TRANSPOSE.&amp;nbsp; &amp;nbsp; You can just use a DATA STEP with an ARRAY that uses YEAR as the index.&amp;nbsp; Something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wide;
   do until(last.id);
      set tall;
      by id;
      array m [2014:2025] y2014-y2025 ;
      if year in (2014:2025) then m[year] = value;
   end;
   drop year value ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And if you want an EXCEL file from your TALL dataset then you might not need to transpose it at all.&amp;nbsp; Just use ODS EXCEL and PROC REPROT to make the file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file='myfile.xslx';
proc report data=tall;
   column id value,year;
   define id / group;
   define year/ across ' ';
   define value / sum ' ';
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 01 Sep 2025 14:53:11 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-09-01T14:53:11Z</dc:date>
    <item>
      <title>Transpose Requires Conversion of transposed variable to text but need to export to Excel as number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-Requires-Conversion-of-transposed-variable-to-text-but/m-p/973825#M377747</link>
      <description>&lt;P&gt;I'm developing a program to use an API to call World Bank data for 10-year blocks.&amp;nbsp; The data has one variable ("value") needs to be transposed to meet specific format.&amp;nbsp; The ID for the transposition is the "date" field which is a 4-digit number specifying the year (2015, 2016, etc).&amp;nbsp; SAS does not like using numbers as column names and the transposition leaves the column name with a "_" prefix.&amp;nbsp; I used the&amp;nbsp;VALIDVARNAME=ANY system option to remove the prefix.&amp;nbsp; I am left with a 14-column database where the 10 rightmost columns are now numbers stored as characters (including the column name).&amp;nbsp; The numbers include a mix of positive and negative values across a series (i.e., same row, across the 10 years) and some series have very large numbers while some series are small but have a large number of significant digits after the decimal point.&amp;nbsp; I want to export those 10 columns to Excel as numbers, including the column name (i.e., a year) while retaining the 1st 4 columns as character fields.&amp;nbsp; Seems like Proc Export can't change the formatting and, I will need to use ODS Excel and something called TAGATTR='format', which is new to me.&amp;nbsp; I'll learn.&amp;nbsp; But I'll throw in one more caveat:&amp;nbsp; the column names, which again are years like 2015, 2016, etc... will change when I run the program for different 10-year time periods, so the variables that TAGATTR will reformat needs to be dynamic.&amp;nbsp; Am I missing a simpler solution?&amp;nbsp; If not, how can I create a dynamic TAGATTR formatting?&amp;nbsp; Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 01 Sep 2025 09:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-Requires-Conversion-of-transposed-variable-to-text-but/m-p/973825#M377747</guid>
      <dc:creator>texasmfp</dc:creator>
      <dc:date>2025-09-01T09:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Requires Conversion of transposed variable to text but need to export to Excel as numb</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-Requires-Conversion-of-transposed-variable-to-text-but/m-p/973844#M377753</link>
      <description>&lt;P&gt;can you explain what you want to create it more detail?&amp;nbsp; It would help if you showed an example input dataset and the output you want from it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also explain the reasons for any restrictions. For example why does it matter if the column headers in the EXCEL file are character strings instead of numbers?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note if you are using the YEAR value as the indication of what variable to transpose into then you probably do NOT need to use PROC TRANSPOSE.&amp;nbsp; &amp;nbsp; You can just use a DATA STEP with an ARRAY that uses YEAR as the index.&amp;nbsp; Something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wide;
   do until(last.id);
      set tall;
      by id;
      array m [2014:2025] y2014-y2025 ;
      if year in (2014:2025) then m[year] = value;
   end;
   drop year value ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And if you want an EXCEL file from your TALL dataset then you might not need to transpose it at all.&amp;nbsp; Just use ODS EXCEL and PROC REPROT to make the file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file='myfile.xslx';
proc report data=tall;
   column id value,year;
   define id / group;
   define year/ across ' ';
   define value / sum ' ';
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Sep 2025 14:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-Requires-Conversion-of-transposed-variable-to-text-but/m-p/973844#M377753</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-01T14:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Requires Conversion of transposed variable to text but need to export to Excel as numb</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-Requires-Conversion-of-transposed-variable-to-text-but/m-p/973871#M377760</link>
      <description>The most simple solution is changing all these variables into CHARACTER type variables &lt;BR /&gt;or add TAB character before it. Like:&lt;BR /&gt;new_var=cats('09'x,var);&lt;BR /&gt;&lt;BR /&gt;And it is better to post your example data and desired output.</description>
      <pubDate>Tue, 02 Sep 2025 07:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-Requires-Conversion-of-transposed-variable-to-text-but/m-p/973871#M377760</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-09-02T07:21:38Z</dc:date>
    </item>
  </channel>
</rss>

