<?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: How to sum up the value of columns and input this value in another table? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328799#M73455</link>
    <description>&lt;P&gt;All you need is a small change in 2nd step.&lt;/P&gt;
&lt;P&gt;If you want to count rows dismiss &lt;STRONG&gt;distinct&lt;/STRONG&gt;&amp;nbsp; in 1st step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;select count(distinct custs) &amp;nbsp;into : cnt&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from&amp;nbsp;&lt;SPAN&gt;Yin.Accounts_final_sb;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data&amp;nbsp; Yin.Pacs_all;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; set&amp;nbsp; Yin.Pacs_all;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; retain &lt;STRONG&gt;custs&lt;/STRONG&gt; &amp;amp;cnt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2017 16:07:55 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-01-31T16:07:55Z</dc:date>
    <item>
      <title>How to sum up the value of columns and input this value in another table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328770#M73443</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I have a problem in sas programming.&lt;/P&gt;&lt;P&gt;What I need to do is first to count how many custs in total in Yin.Accounts_final_sb file. In other words, I need to add all the numbers in custs colums, and there are more than 150k columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7035iFECF5F3B2539E1BA/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Captur11e.PNG" title="Captur11e.PNG" /&gt;&lt;/P&gt;&lt;P&gt;Secondly, after getting the number of total custs, I will need to create a new column called custs and input the number under below in Yin.Pacs_all file.&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7034iBC1A4F43BB84F589/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;&lt;P&gt;Anyone can help me?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 15:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328770#M73443</guid>
      <dc:creator>Muyu</dc:creator>
      <dc:date>2017-01-31T15:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up the value of columns and input this value in another table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328786#M73448</link>
      <description>&lt;P&gt;try code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;select count(distinct custs) &amp;nbsp;into : cnt&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from&amp;nbsp;&lt;SPAN&gt;Yin.Accounts_final_sb;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data&amp;nbsp; Yin.Pacs_all;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; set&amp;nbsp; Yin.Pacs_all;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; retain cnt_cust &amp;amp;cnt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 15:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328786#M73448</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-31T15:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up the value of columns and input this value in another table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328793#M73451</link>
      <description>&lt;P&gt;Some clarification:&lt;/P&gt;
&lt;P&gt;You say "&amp;nbsp;count how many custs in total " and "add all the numbers in custs colums". Do want a count or sum? "Add" implies addition or sum of numbers.&lt;/P&gt;
&lt;P&gt;Also for a count do you want to count rows or unique number of values for Custs?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You say "after getting the number of total custs, I will need to create a new column called custs and input the number under below in Yin.Pacs_all ". Does that Yin.Pacs_all already exist? You don't show a variable custs so this is somewhat confusing. If there is no existing variable custs in the data set then you will need to create a new data set as adding variables after a set is created is not one of SAS's features. You could rename the data set after combining the values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To clarify the problem it helps to post example data as a data step with the variables concerned and then show a desired result for the example data. All you need a is few rows that you can calculate by hand to show the desired result. Since the only variable I see you asking about from your existing data is custs the example data step code to create an example set could be this:&lt;/P&gt;
&lt;PRE&gt;data have;
   input custs;
datalines;
149
150
151
151
152
;
run;&lt;/PRE&gt;
&lt;P&gt;And then you ask for a count of custs=5, or a count of unique cust values=4, that you need to combine into an existing data set. We need to know which type of count you want to do to create the correct summary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To combine with an existing data set of one record it may be as simple as this (summarydata is a data set that has the correct count of custs)&lt;/P&gt;
&lt;PRE&gt;data want;
   merge Yin.Pacs_all
       summarydata
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Depending on which count you want here are two ways:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table summarydata as
   select count(custs) as custs 
   from Yin.Accounts_final_sb;
quit;
/* for count of unique cust values*/
proc sql;
   create table summarydata as
   select count(custs) as custs 
   from (select distinct custs from Yin.Accounts_final_sb);
quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2017 16:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328793#M73451</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-31T16:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up the value of columns and input this value in another table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328796#M73452</link>
      <description>&lt;P&gt;Seems it does not work...&lt;/P&gt;&lt;P&gt;To be specific, what I want is to add a column like below.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7040i24F516C1969A9485/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Captur1e.PNG" title="Captur1e.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 16:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328796#M73452</guid>
      <dc:creator>Muyu</dc:creator>
      <dc:date>2017-01-31T16:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up the value of columns and input this value in another table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328799#M73455</link>
      <description>&lt;P&gt;All you need is a small change in 2nd step.&lt;/P&gt;
&lt;P&gt;If you want to count rows dismiss &lt;STRONG&gt;distinct&lt;/STRONG&gt;&amp;nbsp; in 1st step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;select count(distinct custs) &amp;nbsp;into : cnt&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from&amp;nbsp;&lt;SPAN&gt;Yin.Accounts_final_sb;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data&amp;nbsp; Yin.Pacs_all;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; set&amp;nbsp; Yin.Pacs_all;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; retain &lt;STRONG&gt;custs&lt;/STRONG&gt; &amp;amp;cnt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 16:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-the-value-of-columns-and-input-this-value-in/m-p/328799#M73455</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-31T16:07:55Z</dc:date>
    </item>
  </channel>
</rss>

