<?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 How to divide one variable to to another variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-divide-one-variable-to-to-another-variable/m-p/843513#M333476</link>
    <description>&lt;P&gt;Hi There.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this data, data A &amp;amp; B&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curious_guy_0-1668049419766.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77146i053E8E37EF369472/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curious_guy_0-1668049419766.png" alt="curious_guy_0-1668049419766.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curious_guy_1-1668049440654.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77147iB163F37FCD24C182/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curious_guy_1-1668049440654.png" alt="curious_guy_1-1668049440654.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to ask your expertise how to divide value from &lt;EM&gt;total_balance&lt;/EM&gt; (Data A) to every var cell in data B for each year to get the percentage, so it will show like the picture below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curious_guy_2-1668049635037.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77148i55A52942688ED22B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curious_guy_2-1668049635037.png" alt="curious_guy_2-1668049635037.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I usually do this manually on excel and I want to improve this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;generate Data A&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;proc tabulate data = data_a;&lt;BR /&gt;table year, total_balance;&lt;BR /&gt;var total_balance;&lt;BR /&gt;class year;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;generate Data B&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;proc tabulate data = lnsx3by;&lt;BR /&gt;table year, MOBx*balance;&lt;BR /&gt;var balance;&lt;BR /&gt;class year MOBx;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Nov 2022 03:14:59 GMT</pubDate>
    <dc:creator>curious_guy</dc:creator>
    <dc:date>2022-11-10T03:14:59Z</dc:date>
    <item>
      <title>How to divide one variable to to another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-divide-one-variable-to-to-another-variable/m-p/843513#M333476</link>
      <description>&lt;P&gt;Hi There.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this data, data A &amp;amp; B&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curious_guy_0-1668049419766.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77146i053E8E37EF369472/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curious_guy_0-1668049419766.png" alt="curious_guy_0-1668049419766.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curious_guy_1-1668049440654.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77147iB163F37FCD24C182/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curious_guy_1-1668049440654.png" alt="curious_guy_1-1668049440654.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to ask your expertise how to divide value from &lt;EM&gt;total_balance&lt;/EM&gt; (Data A) to every var cell in data B for each year to get the percentage, so it will show like the picture below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curious_guy_2-1668049635037.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77148i55A52942688ED22B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curious_guy_2-1668049635037.png" alt="curious_guy_2-1668049635037.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I usually do this manually on excel and I want to improve this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;generate Data A&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;proc tabulate data = data_a;&lt;BR /&gt;table year, total_balance;&lt;BR /&gt;var total_balance;&lt;BR /&gt;class year;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;generate Data B&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;proc tabulate data = lnsx3by;&lt;BR /&gt;table year, MOBx*balance;&lt;BR /&gt;var balance;&lt;BR /&gt;class year MOBx;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 03:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-divide-one-variable-to-to-another-variable/m-p/843513#M333476</guid>
      <dc:creator>curious_guy</dc:creator>
      <dc:date>2022-11-10T03:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to divide one variable to to another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-divide-one-variable-to-to-another-variable/m-p/843515#M333478</link>
      <description>&lt;P&gt;Since you only posted pictures we have to make a lot of guesses at what data you actually have.&lt;/P&gt;
&lt;P&gt;It sounds to me like you one dataset with two variables YEAR and TOTAL_BALANCE.&lt;/P&gt;
&lt;P&gt;And a second dataset with YEAR, MOBX and BALANCE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it sounds like you just want to MERGE the two by YEAR and then DIVIDE the two numbers to make a percentage.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge b a ;
  by year ;
  percent = balance/total_balance.
  format percent percent6. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Nov 2022 04:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-divide-one-variable-to-to-another-variable/m-p/843515#M333478</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-10T04:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to divide one variable to to another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-divide-one-variable-to-to-another-variable/m-p/843516#M333479</link>
      <description>Hi Tom. thank you for your answer. Understand that my question seems guessing for the reader. I've try with your code and understand your point. Thank you tom &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 10 Nov 2022 04:42:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-divide-one-variable-to-to-another-variable/m-p/843516#M333479</guid>
      <dc:creator>curious_guy</dc:creator>
      <dc:date>2022-11-10T04:42:21Z</dc:date>
    </item>
  </channel>
</rss>

