<?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: Sum Function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829532#M327752</link>
    <description>&lt;P&gt;You did not provide full working code, but you asked why the two function calls were different. I pointed out the obvious difference that they used two different variable lists. Armed with that insight, you should be able to run your actual code and see what is going on.&lt;/P&gt;</description>
    <pubDate>Sun, 21 Aug 2022 01:13:08 GMT</pubDate>
    <dc:creator>WarrenKuhfeld</dc:creator>
    <dc:date>2022-08-21T01:13:08Z</dc:date>
    <item>
      <title>Sum Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829467#M327723</link>
      <description>&lt;P&gt;I am trying to calculate a sum of several variables using the SUM function. I get different totals when I use a list versus specifying each individual variable in the paraenthesis. What's going on here?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* 	8. Female, Black, Untreated, Non-smoker, Non-diabetic */
/***********************************************************/
	else if 	
	gender = 2 and
	race_all = 4 and 
	htn_meds = 2 and
	smk_status ne 1 and
	ever_told_dm2 ne 1
	
	then do; 
	ascvd_age = log(age_yrs)*(17.114);
	ascvd_tchol = log(tchol_mg)*0.940;
	ascvd_hdl = log(hdl_mg)*(-18.920);
	
/* 	Interaction - age and HDL */
	ascvd_age_x_hdl = log(age_yrs)*log(hdl_mg)*(4.475);
	
/* 	Untreated SBP */
	ascvd_sbp_notx = log(mean_sbp)*27.820;
	
/* 	Interaction - age and UNTREATED SBP */
	ascvd_age_x_sbp_notx = log(age_yrs)*log(mean_sbp)*(-6.087);
	
/* 	Non-smoker */
	ascvd_smk = 0*(0.691);
	
/* 	Non-diabetic */
	ascvd_ever_told_dm2 = 0*(0.874);

/***********************************************************/
	&lt;FONT color="#FF0000"&gt;ind_sum_blk_f_wtf&lt;/FONT&gt; = sum(of ascvd_:);
	&lt;FONT color="#3366FF"&gt;ind_sum_blk_f&lt;/FONT&gt; = sum(ascvd_age, ascvd_tchol, ascvd_hdl, ascvd_age_x_hdl, ascvd_sbp_notx, ascvd_age_x_sbp_notx, ascvd_smk, ascvd_ever_told_dm2);
		
	mean_blk_f = 86.61;
	
	bline_surv_blk_f = 0.9533;
	
	ascvd_score = (1 - bline_surv_blk_f**(exp(ind_sum_blk_f - mean_blk_f)))*100;
	
	end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;ind_sum_blk_f_wtf&lt;/FONT&gt;=102.55228166&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#3366FF"&gt;ind_sum_blk_f&lt;/FONT&gt;=87.81412573 (&lt;FONT color="#3366FF"&gt;this is the correct/desired value&lt;/FONT&gt;)&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 01:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829467#M327723</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2022-08-20T01:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829470#M327725</link>
      <description>&lt;P&gt;The variable&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;ascvd_score&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is in your first list (of ascdv_) but not the second.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 02:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829470#M327725</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2022-08-20T02:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829526#M327747</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16777"&gt;@WarrenKuhfeld&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you suggesting that ascvd_score is being included in the calculation of the sum? How could this be if the SUM function precedes the creation of that variable?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 22:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829526#M327747</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2022-08-20T22:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829527#M327748</link>
      <description>&lt;P&gt;What if the variable is already in the incoming dataset?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 22:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829527#M327748</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-20T22:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829529#M327749</link>
      <description>&lt;P&gt;There must be some other variable that starts with ascvd_ which you are not expecting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To see it, suggest you add:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put (ascvd_:) (=);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Before the assignment statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That should show you all of the variables in the ascvd_: variable list.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2022 00:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829529#M327749</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-08-21T00:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829532#M327752</link>
      <description>&lt;P&gt;You did not provide full working code, but you asked why the two function calls were different. I pointed out the obvious difference that they used two different variable lists. Armed with that insight, you should be able to run your actual code and see what is going on.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2022 01:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-Function/m-p/829532#M327752</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2022-08-21T01:13:08Z</dc:date>
    </item>
  </channel>
</rss>

