<?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: Inserting the value of a variable into a text string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865296#M341704</link>
    <description>&lt;P&gt;How are you sending the SAS data set to excel for viewing?&lt;/P&gt;</description>
    <pubDate>Mon, 20 Mar 2023 19:53:49 GMT</pubDate>
    <dc:creator>russt_sas</dc:creator>
    <dc:date>2023-03-20T19:53:49Z</dc:date>
    <item>
      <title>Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865281#M341696</link>
      <description>&lt;P&gt;I'm trying to insert a formula into an Excel spreadsheet that will be created by SAS.&amp;nbsp; There are 2 header rows in the Excel file, so I have to adjust the row number accordingly.&amp;nbsp; The below code works as a proof of concept, but unfortunately the actual formula is more complex.&amp;nbsp; When I try to create a formula with multiple columns, I get errors or the end result actually includes the text "row_number_adj" instead of the actual row number.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The actual formula (as it should appear in Excel) is&lt;/P&gt;
&lt;P&gt;=(W3+Y3)*(20/26)")&lt;/P&gt;
&lt;P&gt;where 3 should be replaced by the value of row_number_adj&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want; SET have;
	row_number = _N_;
	row_number_adj = row_number + 2;
	Excelformula = COMPRESS("=W"||row_number_adj);
	row_score = cats(Excelformula);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 18:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865281#M341696</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-20T18:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865282#M341697</link>
      <description>Sorry, the formula in Excel should be =(W3+Y3)*(20/26)</description>
      <pubDate>Mon, 20 Mar 2023 18:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865282#M341697</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-20T18:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865285#M341698</link>
      <description>&lt;P&gt;&amp;nbsp;Are you wanting SAS to create something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;=(W3+Y3)*(20/26)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;=(W4+Y4)*(20/26)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;=(W5+Y5)*(20/26)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 18:26:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865285#M341698</guid>
      <dc:creator>russt_sas</dc:creator>
      <dc:date>2023-03-20T18:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865286#M341699</link>
      <description>Yes, so it will apply that formula for each row</description>
      <pubDate>Mon, 20 Mar 2023 18:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865286#M341699</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-20T18:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865287#M341700</link>
      <description>&lt;P&gt;Something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA want; SET have; &lt;BR /&gt;row_number = _N_; &lt;BR /&gt;row_number_adj = row_number + 2; &lt;BR /&gt;Excelformula = COMPRESS("=(W"||row_number_adj||'+'||'Y'||row_number_adj||')'); &lt;BR /&gt;row_score = cats(Excelformula,'*(20/26)'); &lt;BR /&gt;RUN; &lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 18:30:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865287#M341700</guid>
      <dc:creator>russt_sas</dc:creator>
      <dc:date>2023-03-20T18:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865292#M341701</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43460"&gt;@russt_sas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA want; SET have; &lt;BR /&gt;row_number = _N_; &lt;BR /&gt;row_number_adj = row_number + 2; &lt;BR /&gt;Excelformula = COMPRESS("=(W"||row_number_adj||'+'||'Y'||row_number_adj||')'); &lt;BR /&gt;row_score = cats(Excelformula,'*(20/26)'); &lt;BR /&gt;RUN;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's really really close, but for some reason it's inserting a line return after the = sign.&amp;nbsp; So it displays in Excel as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;=&lt;BR /&gt;(W3+Y3)*(20/26)&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 18:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865292#M341701</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-20T18:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865296#M341704</link>
      <description>&lt;P&gt;How are you sending the SAS data set to excel for viewing?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 19:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865296#M341704</guid>
      <dc:creator>russt_sas</dc:creator>
      <dc:date>2023-03-20T19:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865297#M341705</link>
      <description>With ODS Excel and Proc Report.  I also noticed that the character fields in Excel have text wrapping on by default.  That could explain why there is a break between the = and the W.  On the other hand, manually turning off the text wrap in Excel does NOT make the formula calculate.</description>
      <pubDate>Mon, 20 Mar 2023 20:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865297#M341705</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-20T20:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865301#M341708</link>
      <description>&lt;P&gt;Can you attach the exact code that is not working for you?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 20:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865301#M341708</guid>
      <dc:creator>russt_sas</dc:creator>
      <dc:date>2023-03-20T20:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865303#M341710</link>
      <description>&lt;P&gt;You want to create a character variable that has a string that looks like an formula you could type into Excel?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  string=cats('=(w',_n_+2,'+y',_n_+2,')*(20/26)');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What do you plan to do with this formula? Are you going to try and write it into an Excel spreadsheet so that it will actually perform calculations? Why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 20:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865303#M341710</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-20T20:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865304#M341711</link>
      <description>&lt;P&gt;I'm trying to use a longer version of the formula:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want; SET havet;
	DROP row_number row_number_adj Excelformula;
	row_number = _N_;
	row_number_adj = row_number + 2;
  Excelformula = COMPRESS("=(W"||row_number_adj||'+'||'Y'||row_number_adj||'+'||'AA'||row_number_adj||'+'||'AC'||row_number_adj||'+'||'AE'||row_number_adj||'+'||'AG'||row_number_adj||'+'||'AI'||row_number_adj||'+'||'AK'||row_number_adj||'+'||'AM'||row_number_adj||'+'||'AO'||row_number_adj||'+'||'AQ'||row_number_adj||'+'||'AS'||row_number_adj||'+'||'AU'||row_number_adj||'+'||'AW'||row_number_adj||'+'||'AY'||row_number_adj||'+'||'BA'||row_number_adj||'+'||'BC'||row_number_adj||'+'||'BE'||row_number_adj||'+'||'BG'||row_number_adj||'+'||'BI'||row_number_adj||'+'||'BK'||row_number_adj||'+'||'BM'||row_number_adj||'+'||'BO'||row_number_adj||'+'||'BQ'||row_number_adj||'+'||'BS'||row_number_adj||'+'||'BU'||row_number_adj||')');
	row_score = cats(Excelformula,'*(20/26)'); 
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Mar 2023 20:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865304#M341711</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-20T20:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865306#M341713</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You want to create a character variable that has a string that looks like an formula you could type into Excel?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  string=cats('=(w',_n_+2,'+y',_n_+2,')*(20/26)');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What do you plan to do with this formula? Are you going to try and write it into an Excel spreadsheet so that it will actually perform calculations? Why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, it should look like a formula that Excel could use.&amp;nbsp; Another team will use a series of these Excel files (more than 70 of them) to manually audit various groups of records for agreement -- 1 is there is agreement between our the 2 data sources, and 0 if there is not.&amp;nbsp; The Excel file has columns is this type of order: Variable1, Score1, Variable2, Score2, etc.&amp;nbsp; The audit team has requested that I put the formula in place at the end of the row to save them a lot of copying, pasting, and auto-filling down the column.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 21:15:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865306#M341713</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-20T21:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865309#M341716</link>
      <description>&lt;P&gt;Why are you using COMPRESS()?&amp;nbsp; You seem to already know about CATS(), so why not just use it?&lt;/P&gt;
&lt;P&gt;But why not just use TRANWRD() instead?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length formula $200 ;
formula='=W3+Y3+AA3+AC3+AE3+AG3+AI3+AK3+AM3+AO3+AQ3+AS3+AU3+AW3+AY3+BA3+BC3+BE3+BG3+BI3+BK3+BM3+BO3+BQ3+BS3+BU3';
formula=tranwrd(formula,'3',cats(_n_+2));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Mar 2023 21:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865309#M341716</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-20T21:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865310#M341717</link>
      <description>&lt;P&gt;Why not just put the actual sum instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  total = sum(of score:);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Mar 2023 21:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865310#M341717</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-20T21:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865429#M341768</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Why not just put the actual sum instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  total = sum(of score:);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Because the score variables are blank in SAS.&amp;nbsp; The audit team will fill in the score fields in Excel as they do their comparison.&amp;nbsp; So the idea is that the formula will already be present at the end of each row and will automatically calculate the row score.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 13:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865429#M341768</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-21T13:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865435#M341771</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Why are you using COMPRESS()?&amp;nbsp; You seem to already know about CATS(), so why not just use it?&lt;/P&gt;
&lt;P&gt;But why not just use TRANWRD() instead?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length formula $200 ;
formula='=W3+Y3+AA3+AC3+AE3+AG3+AI3+AK3+AM3+AO3+AQ3+AS3+AU3+AW3+AY3+BA3+BC3+BE3+BG3+BI3+BK3+BM3+BO3+BQ3+BS3+BU3';
formula=tranwrd(formula,'3',cats(_n_+2));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This works and is the simplest way I've seen to do it, but Excel is seeing it as a text string rather that a formula.&amp;nbsp; In other words, the cell displays this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;=W3+Y3+AA3+AC3+AE3+AG3+AI3+AK3+AM3+AO3&lt;BR /&gt;+AQ3+AS3+AU3+AW3+AY3+BA3+BC3+BE3+BG3&lt;BR /&gt;+BI3+BK3+BM3+BO3+BQ3+BS3+BU3*(20/26)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I double-click on the cell and then press enter, it will calculate properly.&amp;nbsp; But that's a lot of extra clicking for the audit team.&amp;nbsp; Unfortunately, this seems like an Excel issue rather than a SAS issue.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 14:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865435#M341771</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-21T14:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865438#M341772</link>
      <description>&lt;P&gt;So you have now moved onto your actual problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you creating the EXCEL file from the dataset?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What options did you try to tell SAS that it should treat the value of that variable as Excel CODE instead of TEXT?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try the&amp;nbsp;formulas='on' option to ODS EXCEL?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Writing-Excel-formulas-in-SAS-using-ods/m-p/824430/highlight/true#M325599" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Writing-Excel-formulas-in-SAS-using-ods/m-p/824430/highlight/true#M325599&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 14:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865438#M341772</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-21T14:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865441#M341773</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So you have now moved onto your actual problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you creating the EXCEL file from the dataset?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What options did you try to tell SAS that it should treat the value of that variable as Excel CODE instead of TEXT?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try the&amp;nbsp;formulas='on' option to ODS EXCEL?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Writing-Excel-formulas-in-SAS-using-ods/m-p/824430/highlight/true#M325599" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Writing-Excel-formulas-in-SAS-using-ods/m-p/824430/highlight/true#M325599&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I did not have the formulas option turned on, so that got my hopes up... unfortunately it's still doing the same thing &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp; Here is my current ODS Excel command:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel options(sheet_name='Scoring Sheet' sheet_interval='now' frozen_headers='on' formulas='on');
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Mar 2023 14:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865441#M341773</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-21T14:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865455#M341779</link>
      <description>&lt;P&gt;HI:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Have you thought about specifying the formula using TAGATTR? For example, in the code below, the EX1 workbook uses the data values for ACTUAL and PREDICT to calculate DIFF. But if I change any of those values in the worksheet after opening, the value for DIFF changes as soon as the value for either ACTUAL or PREDICT changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; However, as shown in EX2, if I use computed items that are initially set to 0 (called C_ACT and C_PRED), then the columns are initially 0 when I open the output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1679411738072.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81824i0BE76E926ACBC2C4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1679411738072.png" alt="Cynthia_sas_0-1679411738072.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; But as soon as I update the columns with values, the DIFF column changes:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_1-1679411762143.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81825i8BE8E6A99BA421FE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_1-1679411762143.png" alt="Cynthia_sas_1-1679411762143.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The code below shows both examples, but the screen shots are from the workbook created in EX2 code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
  ods excel file='c:\temp\formula_ex1.xlsx';

  proc report data=sashelp.prdsale spanrows;
     where country eq 'CANADA' and year eq 1993;
     column country prodtype product actual predict diff;
	 define country / group;
	 define prodtype / group;
	 define product / group;
     define predict / sum style(column)={tagattr='format:Currency'};
     define actual / sum style(column)={tagattr='format:Currency'};
     define diff / computed 
            style(column)={width=1in tagattr='format:Currency formula:RC[-1]-RC[-2]'};
     compute diff;
	   diff=0;
	 endcomp;
  run;
  ods excel close;

  
  ods excel file='c:\temp\formula_ex2.xlsx';

  proc report data=sashelp.prdsale spanrows;
     where country eq 'CANADA' and year eq 1993;
     column country prodtype product c_act c_pred diff;
	 define country / group;
	 define prodtype / group;
	 define product / group;
     define c_pred / computed style(column)={tagattr='format:Currency'};
     define c_act / computed style(column)={tagattr='format:Currency'};
	 compute c_pred;
	   c_pred = 0;
	 endcomp;
	 compute c_act;
	   c_act = 0;
	 endcomp;
     define diff / computed 
            style(column)={width=1in tagattr='format:Currency formula:RC[-1]-RC[-2]'};
     compute diff;
	   diff=0;
	 endcomp;
  run;
  ods excel close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; Using TAGATTR is an alternative approach.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 15:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865455#M341779</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2023-03-21T15:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting the value of a variable into a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865481#M341791</link>
      <description>&lt;P&gt;The issue seems to be with the extremely long string required by the formula.&amp;nbsp; I cannot figure out if there is a way to prevent the length from causing the formula to be seen as text by Excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps using this FORMULA&amp;nbsp; tag will work instead, that does not seem to be impacted by the use of a very long formula.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So assuming that the original request to sum every other column from column 23 to 73 could be recoded as meaning to sum every other relative cell from -1 to -51 then perhaps something like this will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    define total_score / computed 
            style(column)={width=1in tagattr='formula:RC[-1]+RC[-3]+RC[-5]+RC[-7]+RC[-9]+RC[-11]+RC[-13]+RC[-15]+RC[-17]+RC[-19]+RC[-21]+RC[-23]+RC[-25]+RC[-27]+RC[-29]+RC[-31]+RC[-33]+
RC[-35]+RC[-37]+RC[-39]+RC[-41]+RC[-43]+RC[-45]+RC[-47]+RC[-49]+RC[-51]'};
     compute diff;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 16:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-the-value-of-a-variable-into-a-text-string/m-p/865481#M341791</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-21T16:43:14Z</dc:date>
    </item>
  </channel>
</rss>

