<?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: Creating a sumproduct - Should be easy in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214919#M52907</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you want your final output to be?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on the output I would consider using a proc freq with weights and summing those results instead. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Jun 2015 17:51:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-06-26T17:51:03Z</dc:date>
    <item>
      <title>Creating a sumproduct - Should be easy</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214918#M52906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK so I'm new(ish) to SAS. I feel like this is probably very simple and I'm missing something very easy and obvious but for the life of me I cannot figure out why this isn't working. Can anyone help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input obs Condition0001 Condition0002 CCS_1 CCS_2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Cards;&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1 5 10 1 2&lt;/P&gt;&lt;P&gt;&amp;nbsp; 2 6 8 2 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Array ArrayCondition[2] Condition0001-Condition0002;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Array ArrayCCS[2] CCS_1-CCS_2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Sumproduct = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Do i =1 to i = 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Sumproduct = sum(Sumproduct, (ArrayCondition&lt;I&gt;*ArrayCCS&lt;I&gt;));&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; End;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Freq = sum(of ArrayCondition&lt;LI&gt;);&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Score = Sumproduct/Freq;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically what I want this to do is add a column "Sumproduct" which should be the sumproduct of my two array's (=Condition0001*CCS_1 + Condition0002*CCS_2).&lt;/P&gt;&lt;P&gt;The code runs fine but the sumproduct ends up being 0 everytime. Is something getting reset in my do statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be extremely appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jun 2015 17:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214918#M52906</guid>
      <dc:creator>ZColl</dc:creator>
      <dc:date>2015-06-26T17:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a sumproduct - Should be easy</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214919#M52907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you want your final output to be?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on the output I would consider using a proc freq with weights and summing those results instead. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jun 2015 17:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214919#M52907</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-06-26T17:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a sumproduct - Should be easy</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214920#M52908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just realized what I was doing wrong. I'm an idiot.&lt;/P&gt;&lt;P&gt;Do i =1 to i = 2; &amp;lt;- WRONG&lt;/P&gt;&lt;P&gt;Do i = 1 to 2; &amp;lt;- RIGHT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry about that. Thanks for looking at it though&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jun 2015 17:58:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214920#M52908</guid>
      <dc:creator>ZColl</dc:creator>
      <dc:date>2015-06-26T17:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a sumproduct - Should be easy</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214921#M52909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad it worked out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did want to note that you're looking at a dataset using matrix algebra which is better suited to IML not BASE SAS. SAS operates a bit differently than most other statistical packages in that respects.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jun 2015 18:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214921#M52909</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-06-26T18:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a sumproduct - Should be easy</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214922#M52910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So the code I posted above is actually for a sample data set. The real data set I have is considerably larger. The code is working for the above sample but for the real dataset it is understating the sumproduct. So I'm wondering &lt;STRONG&gt;do array's in SAS have an element maximum&lt;/STRONG&gt;? I was attempting create my arrays over 283 variables. I did some checking work in excel and it looks like the sumproduct SAS is returning is the sumproduct of only the first 247-248 of those columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, I guess I'll split my arrays into two.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not familiar with IML. I'm doing this for a work project. Generally, I am able to use excel and access for almost everything I do but this dataset was too big for excel and when I tried to use it in Access I learned that Access has a 255 column limit. So I tried my hand at SAS. Not sure if the company offers IML or not.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jun 2015 20:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214922#M52910</guid>
      <dc:creator>ZColl</dc:creator>
      <dc:date>2015-06-26T20:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a sumproduct - Should be easy</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214923#M52911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No limit that I'm aware of, if you use code similar to below do you get the value you get in Excel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test_flipped;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;array cond(*) condition0001-condition0002;&lt;/P&gt;&lt;P&gt;array ccs(*) ccs_1 - ccs_2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i=1 to dim(cond);&lt;/P&gt;&lt;P&gt;condition=cond(i);&lt;/P&gt;&lt;P&gt;ccs_weight=ccs(i);&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data=test_flipped sum;&lt;/P&gt;&lt;P&gt;var condition;&lt;/P&gt;&lt;P&gt;weight ccs_weight;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jun 2015 22:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214923#M52911</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-06-26T22:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a sumproduct - Should be easy</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214924#M52912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok it's running now. I'll let you know if it works when it finishes. In the mean time can you explain to me how this part works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;do i=1 to dim(cond);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;condition=cond(i);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;ccs_weight=ccs(i);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;output;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;end;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;So I'm assuming the dim(cond) returns the number of elements found in the cond array. Very useful to me as I was looking for something like this earlier.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;But I don't understand what the statements inside the do statement are doing. Wouldn't the outcome of that be the final iteration of the do statement since it will override itself each time. Maybe I'm looking at this wrong....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jun 2015 22:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214924#M52912</guid>
      <dc:creator>ZColl</dc:creator>
      <dc:date>2015-06-26T22:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a sumproduct - Should be easy</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214925#M52913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is using an array method to flip the data so it's long rather than wide. The array loops through the variables and outputs each observation to a new line which can then be processed more easily by proc means and other SAS procs. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;data test_flipped;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;set test;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;array cond(*) condition0001-condition0002;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;array ccs(*) ccs_1 - ccs_2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;do i=1 to dim(cond);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;condition=cond(i);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;ccs_weight=ccs(i);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;output;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;end;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;drop &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;condition0001-condition0002&lt;/SPAN&gt; ccs_1-ccs_2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Here's a bit of write up on how that works:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/modules/widetolong_data.htm" title="http://www.ats.ucla.edu/stat/sas/modules/widetolong_data.htm"&gt;SAS Learning Module: Reshaping wide to long using a data step&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jun 2015 23:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-sumproduct-Should-be-easy/m-p/214925#M52913</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-06-27T23:50:16Z</dc:date>
    </item>
  </channel>
</rss>

