<?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 use SAS code to calculate sum of every number on the same column and calculate the percen in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243851#M45392</link>
    <description>&lt;P&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Respected-Advisor"&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_self"&gt;&lt;SPAN class="login-bold"&gt;ballardw&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;, thank you.&lt;/P&gt;&lt;P&gt;I got the error message&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ERROR: There are multiple analysis variables associated with a single table cell in the following&lt;BR /&gt;nesting : category * value * year * value * sum * f.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;actually the real data is not year from 2010 to 2016, it is like female2010, female2011, male2010, male2011, trans2010, trans2011, unknow2010, unknow2011&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you please provide an adjusted code. And there is no need for including ID. Thanks. It is ordered by frequency. that is already done prevoiusly&lt;/P&gt;&lt;P&gt;just keep the order&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jan 2016 17:37:41 GMT</pubDate>
    <dc:creator>Bal23</dc:creator>
    <dc:date>2016-01-15T17:37:41Z</dc:date>
    <item>
      <title>how to use SAS code to calculate sum of every number on the same column and calculate the percent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243572#M45303</link>
      <description>&lt;P&gt;I use proc freq to generate numbers. Then, in steading of print out the dataset and calculate later by myself, I want SAS to do extra calculation, to calculate the sum of number of each column, and generate another table, the percentage of each number divided by the sum*100. That is, to have two variables, sum and rate.&lt;/P&gt;&lt;P&gt;My sample data is attached&lt;/P&gt;&lt;P&gt;Would you please recommend a sas code?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 20:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243572#M45303</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-14T20:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243575#M45305</link>
      <description>&lt;P&gt;Please show the desired output for the example data you show in the attachment.&lt;/P&gt;
&lt;P&gt;Also, does the output have to be a data set or are you looking for a report table.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 20:15:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243575#M45305</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-14T20:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243577#M45307</link>
      <description>&lt;P&gt;I have regenerated sample data and output in an excel file attached&lt;/P&gt;&lt;P&gt;i am interested in both generating a dataset and a report table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 20:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243577#M45307</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-14T20:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243578#M45308</link>
      <description>&lt;P&gt;if you cannot open it, here is the pdf file for the output, but the original one is the left one&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 20:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243578#M45308</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-14T20:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243591#M45314</link>
      <description>When I open that file it is empty.</description>
      <pubDate>Thu, 14 Jan 2016 20:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243591#M45314</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-14T20:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243593#M45316</link>
      <description>&lt;P&gt;Proc freq generates percents, rows or columns for your data as well. The output should contain on of the numbers you're looking for, and you might be better off trying to manipulate that output rather than calculate information from scratch.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RTM for options on the TABLES statement.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 21:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243593#M45316</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-14T21:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243596#M45319</link>
      <description>&lt;P&gt;Also, if your example data is the result from proc freq it would probably be better to provide the raw data as the the types of sums and rates your are looking for are possible from various report procedures.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 21:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243596#M45319</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-14T21:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243598#M45320</link>
      <description>&lt;P&gt;Not very elegant but here is a solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;infile cards dsd dlm=' ';&lt;BR /&gt;input obs condition$ year2010 year2011 year2012;&lt;BR /&gt;cards;&lt;BR /&gt;1 a 12 23 45&lt;BR /&gt;2 b 23 45 57&lt;BR /&gt;3 c 45 57 89&lt;BR /&gt;4 d 57 89 20&lt;BR /&gt;5 e 89 20 29&lt;BR /&gt;6 f 20 29 59&lt;BR /&gt;;run;&lt;BR /&gt;&lt;BR /&gt;proc transpose data=have out=tran_have(rename=(_NAME_=Year));by obs condition;var year:;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table sum as&lt;BR /&gt;select *,sum(col1) as sum&lt;BR /&gt;from tran_have&lt;BR /&gt;group by year&lt;BR /&gt;order by condition;&lt;BR /&gt;&lt;BR /&gt;proc transpose data=sum out=tran_sum;by condition;id year;var sum;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select a.year2010/b.year2010*100 as year2010,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.year2011/b.year2011*100 as year2011,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; a.year2012/b.year2012*100 as year2012&lt;BR /&gt;from have a left join&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tran_sum b on&lt;BR /&gt;a.condition=b.condition;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 21:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243598#M45320</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2016-01-14T21:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243622#M45331</link>
      <description>&lt;P&gt;And another using data in the first post for input:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* first get some data to manipulate*/
data junk;
   input obs condition $  Yr2010 Yr2011  Yr201Yr2 Yr2013 Yr2014 Yr2015 Yr2016;
   array y  Yr2010 Yr2011  Yr201Yr2 Yr2013 Yr2014 Yr2015 Yr2016;
   /* this reshapes the data into something that proc tabulate 
   likes better*/
   do i= 1 to dim(y);
      year= 2009+i;
      value = y[i];
      output;
   end;
   keep obs condition year value;
datalines;
1 a                  31     7      98             41     68    41     68
2 b                  93     28     99             32     53    32     53
3 c                  66     2      33             68     44    68     44
4 d                  93     80     58             50     41    50     41
5 e                  74     11     93             73     39    73     39
6 f                  13     71     45             35     39    35     39
7 g                  72     63     61             45     42    45     42
8 h                  57     53     64             53     16    53     16
9 i                   8     14     81             21     92    21     92
;
run;

proc tabulate data=junk;
   class obs condition year;
   var value;
   table obs*condition all='Sum', 
         year='' * value=''*sum*f=best8. 
         year='' * value=''*colpctsum='Rate'*f=f16.8;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the original data used for proc freq consisted of Condition Year and a variable being counted the above might be sufficient changing SUM to N and colpctsum to colpctn and the Value could be left out. Maybe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 22:26:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243622#M45331</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-14T22:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243800#M45372</link>
      <description>&lt;P&gt;Thank you. What is there are some missing values in some blanks. Any adjustment for that?&lt;/P&gt;&lt;P&gt;is "DSD" for this purpose?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 15:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243800#M45372</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-15T15:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243822#M45377</link>
      <description>&lt;P&gt;"Missing values in some blanks" implies data related issues but we need more infomation to see what you mean. Such the input data and the code applied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DSD is only relavent&amp;nbsp;when reading data from or writing to an external file. When reading a file that is delimited, when the delimiter occurs&amp;nbsp;encolsed by quotation marks the delimiter is ignored and 2 consecutive delimiters indicate a missing value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 16:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243822#M45377</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-15T16:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243827#M45379</link>
      <description>&lt;P&gt;Thanks. I have several errors when i run this code.&lt;/P&gt;&lt;P&gt;1. at first, i did not set a variable name as "year"&lt;/P&gt;&lt;P&gt;your code is year2011 2012 etc&lt;/P&gt;&lt;P&gt;so the error was&lt;/P&gt;&lt;P&gt;ERROR: Variable YEAR not found.&lt;BR /&gt;2. Then I set my variable name as "year",&amp;nbsp; although it is not perfect, because it is really not simple year. the first row is more about different catogies with different year. My task is like calculate "child2003" "child2004" "adult2003" "adult2004" "senior2003" "senior2004" so it is not a simple year but a mix of year and categories&lt;/P&gt;&lt;P&gt;my another variable is "category" instead of "condition",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then the error showed below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Data set WORK.HAVE is not sorted in ascending sequence. The current BY group has Category = Pi&lt;BR /&gt;and the next BY group has Category = Is.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 3 observations read from the data set WORK.HAVE.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 16:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243827#M45379</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-15T16:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to use SAS code to calculate sum of every number on the same column and calculate the percen</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243851#M45392</link>
      <description>&lt;P&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Respected-Advisor"&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_self"&gt;&lt;SPAN class="login-bold"&gt;ballardw&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;, thank you.&lt;/P&gt;&lt;P&gt;I got the error message&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ERROR: There are multiple analysis variables associated with a single table cell in the following&lt;BR /&gt;nesting : category * value * year * value * sum * f.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;actually the real data is not year from 2010 to 2016, it is like female2010, female2011, male2010, male2011, trans2010, trans2011, unknow2010, unknow2011&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you please provide an adjusted code. And there is no need for including ID. Thanks. It is ordered by frequency. that is already done prevoiusly&lt;/P&gt;&lt;P&gt;just keep the order&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 17:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-SAS-code-to-calculate-sum-of-every-number-on-the-same/m-p/243851#M45392</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-01-15T17:37:41Z</dc:date>
    </item>
  </channel>
</rss>

