<?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: percetanges od a column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858155#M339059</link>
    <description>&lt;P&gt;Do you need a data set for further manipulation or a report that people read?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best is to provide some example data, or reference one of the SAS supplied data sets such as SASHELP.Class, and walk us through details. The way you say "(first record of number_of_items) / sum of number_of_items" raises lots of concerns about exactly what the output is supposed to look like. With percentages I always want a very clear description of how the total numerator and denominator of any given percentage are obtained.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, did YOU calculate the number_of_items variable? I ask because it may be that step isn't needed depending on exactly what you expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2023 22:51:54 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-02-09T22:51:54Z</dc:date>
    <item>
      <title>percetanges od a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858139#M339049</link>
      <description>&lt;P&gt;Hi, I have a column in my dataset called number_of_items. I want to calculated the percentages of the items. e.g. 100 * (first record of&amp;nbsp;number_of_items) / sum of&amp;nbsp;number_of_items. How do I do this calculation? Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 21:49:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858139#M339049</guid>
      <dc:creator>znhnm</dc:creator>
      <dc:date>2023-02-09T21:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: percetanges od a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858147#M339054</link>
      <description>&lt;P&gt;Please show us some sample data and the desired output&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 22:10:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858147#M339054</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-09T22:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: percetanges od a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858155#M339059</link>
      <description>&lt;P&gt;Do you need a data set for further manipulation or a report that people read?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best is to provide some example data, or reference one of the SAS supplied data sets such as SASHELP.Class, and walk us through details. The way you say "(first record of number_of_items) / sum of number_of_items" raises lots of concerns about exactly what the output is supposed to look like. With percentages I always want a very clear description of how the total numerator and denominator of any given percentage are obtained.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, did YOU calculate the number_of_items variable? I ask because it may be that step isn't needed depending on exactly what you expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 22:51:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858155#M339059</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-09T22:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: percetanges od a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858157#M339061</link>
      <description>&lt;P&gt;Hi, thanks for the reply. &lt;BR /&gt;&lt;BR /&gt;A similar dataset looks like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;data example;
do bin = 1 to 3;
number_of_items = round(rand('uniform')*100);
output;
end;
&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;I want a 3rd column to calculate the percentages.&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 23:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858157#M339061</guid>
      <dc:creator>znhnm</dc:creator>
      <dc:date>2023-02-09T23:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: percetanges od a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858160#M339063</link>
      <description>Hi, I thank you. I provided a sample dataset on the under the other comment. I don't know how to provide an example desired output.</description>
      <pubDate>Thu, 09 Feb 2023 23:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858160#M339063</guid>
      <dc:creator>znhnm</dc:creator>
      <dc:date>2023-02-09T23:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: percetanges od a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858165#M339067</link>
      <description>&lt;P&gt;Instead of a random number lets create a fixed set so we can discuss the actual calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input bin   number_of_items;
datalines;
1  51
2  20
3  49
;&lt;/PRE&gt;
&lt;P&gt;Is this what you are looking for? The Pctn is displayed to two decimals by default. That can be changed with options.&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=have;
   class bin;
   freq number_of_items;
   table bin,
         pctn
   ;
run;&lt;/PRE&gt;
&lt;P&gt;The Freq option makes the procedure treat the data as if there are "number_of_items" identical rows of data so can be used as the N of a statistic.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 00:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858165#M339067</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-10T00:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: percetanges od a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858168#M339070</link>
      <description>Exactly! The calculation is correct! Thanks a lot! However, can I add tis pctn column in my dataset as the 3rd column? I also have anoter column called number_of_items and I want to calculate the pctn2 as the 4th colummn in my current dataset&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Feb 2023 00:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858168#M339070</guid>
      <dc:creator>znhnm</dc:creator>
      <dc:date>2023-02-10T00:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: percetanges od a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858171#M339072</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/411017"&gt;@znhnm&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Exactly! The calculation is correct! Thanks a lot! However, can I add tis pctn column in my dataset as the 3rd column? I also have anoter column called number_of_items and I want to calculate the pctn2 as the 4th colummn in my current dataset&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now you have to provide actual example data. Typically this sound like calculate and then recombine with your existing data.&lt;/P&gt;
&lt;P&gt;Proc Tabulate will create output data sets but it takes a bit to get used to the content. Add an OUT=&amp;lt;datasetname of choice&amp;gt; to the Proc tabulate statement and you can then look at what one looks like. My example would create a pretty simple data set but there will will be variables you don't want related to more complex output possible with the procedure.&lt;/P&gt;
&lt;P&gt;If your other data isn't too ugly it should be possible to MERGE with a data step or join using proc sql.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 00:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percetanges-od-a-column/m-p/858171#M339072</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-10T00:48:57Z</dc:date>
    </item>
  </channel>
</rss>

