<?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: Adding total row or function? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841971#M36506</link>
    <description>&lt;P&gt;Hi, I would want something like this (see below), but as a dataset output and not results (only the "all participants" percentage would be actually needed here):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc tabulate data=test;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;class id nova;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;var kcals;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;table id all='All participants',&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(nova all='Total calories per participant')*&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;kcals=' '*(sum='Total calories' rowpctsum='Percentage')&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/ misstext=' ';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SJ12_0-1667331525590.png" style="width: 466px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76854i31C6C6A80B55706A/image-dimensions/466x147?v=v2" width="466" height="147" role="button" title="SJ12_0-1667331525590.png" alt="SJ12_0-1667331525590.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;OR something that would just indicate: % of kcals from Nova 4 for all participants as a result, for example.&lt;/P&gt;&lt;P&gt;The reason why I didn’t do the proc tabulate directly is because I needed to delete participants that have consumed 0 kcals in total (total of 0 per id) (I don't want their total to be included in the average), explaining why I used that synthax.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2022 19:43:11 GMT</pubDate>
    <dc:creator>SJ12</dc:creator>
    <dc:date>2022-11-01T19:43:11Z</dc:date>
    <item>
      <title>Adding total row or function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841947#M36503</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to use the last dataset below called &lt;STRONG&gt;nova&lt;/STRONG&gt; to add a total row (so I can obtain total kcals for each nova category (total_nova1 to total_nova4)) or directly use a function to obtain the percentage of kcals per category for all participants (to divide the kcals of each category by the grand total). For example, I want to have the % of kcals for total_nova4 for all participants. I'm having difficulty using proc tabulate as I can't use &lt;STRONG&gt;class nova&lt;/STRONG&gt; or &lt;STRONG&gt;var kcals&lt;/STRONG&gt; like I did in the first proc tabulate in the synthax since those variables don't exist in my new dataset nova (I don't know how to identify the variables).&amp;nbsp;The numbers in the last dataset (nova) represent kcals (calories). total_nova1 to total_nova4 represent nova 1-4. Please let me know if I am unclear. I am still new to SAS. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Synthax:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;data test;&lt;/DIV&gt;&lt;DIV&gt;input id foodtype $ Nova $ Subnova $ kcals;&lt;/DIV&gt;&lt;DIV&gt;datalines;&lt;/DIV&gt;&lt;DIV&gt;001 butter 1 oils 10&lt;/DIV&gt;&lt;DIV&gt;001 fish 2 protein 15&lt;/DIV&gt;&lt;DIV&gt;001 banana 3 fruit 10&lt;/DIV&gt;&lt;DIV&gt;001 cherry 4 fruit 25&lt;/DIV&gt;&lt;DIV&gt;002 burger 2 frozen 5&lt;/DIV&gt;&lt;DIV&gt;002 pumpkin 2 other 4&lt;/DIV&gt;&lt;DIV&gt;002 carrot 3 veg 6&lt;/DIV&gt;&lt;DIV&gt;003 apple 1 fruit 100&lt;/DIV&gt;&lt;DIV&gt;003 tahini 4 &amp;nbsp; spread &amp;nbsp; 60&lt;/DIV&gt;&lt;DIV&gt;004 . &amp;nbsp; . &amp;nbsp; &amp;nbsp;. &amp;nbsp; 0&lt;/DIV&gt;&lt;DIV&gt;005 burger &amp;nbsp;2 &amp;nbsp;frozen &amp;nbsp;13&lt;/DIV&gt;&lt;DIV&gt;005 ceral &amp;nbsp;3 grain 56&lt;/DIV&gt;&lt;DIV&gt;005 milk &amp;nbsp;1 &amp;nbsp;prod 35&lt;/DIV&gt;&lt;DIV&gt;005 vinegar 4 &amp;nbsp;Other &amp;nbsp;100&lt;/DIV&gt;&lt;DIV&gt;006 . &amp;nbsp; &amp;nbsp;. &amp;nbsp; . &amp;nbsp; 0&lt;/DIV&gt;&lt;DIV&gt;006 vinegar 4 &amp;nbsp;Other &amp;nbsp;100&lt;/DIV&gt;&lt;DIV&gt;;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc tabulate data=test out=test1;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;class id nova;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;var kcals;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;table id all='All participants',&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (nova all='Total calories per participant')*&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;kcals=' '*(sum='Total calories');&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc print data=test1;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;data nova1;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;set test1;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; where nova="1";&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; total_nova1= kcals_sum;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; if missing(id) then delete;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;keep id total_nova1;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;data nova2;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;set test1;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; where nova="2";&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; total_nova2= kcals_sum;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; if missing(id) then delete;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;keep id total_nova2;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;data nova3;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;set test1;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; where nova="3";&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; total_nova3= kcals_sum;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; if missing(id) then delete;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;keep id total_nova3;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;data nova4;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;set test1;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; where nova="4";&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; total_nova4= kcals_sum;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; if missing(id) then delete;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;keep id total_nova4;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=nova1;by id;run;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=nova2;by id;run;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=nova3;by id;run;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=nova4;by id;run;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data nova;&lt;/DIV&gt;&lt;DIV&gt;merge nova1 nova2 nova3 nova4;&lt;/DIV&gt;&lt;DIV&gt;by id;&lt;/DIV&gt;&lt;DIV&gt;total=sum(total_nova1, total_nova2,total_nova3, total_nova4);&lt;/DIV&gt;&lt;DIV&gt;if total=. then delete;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 Nov 2022 18:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841947#M36503</guid>
      <dc:creator>SJ12</dc:creator>
      <dc:date>2022-11-01T18:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Adding total row or function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841952#M36504</link>
      <description>&lt;P&gt;You don't show us exactly what you want after you create NOVA. It's not clear to me from reading your words what is next. I have simplified your code and calculated percents in data set WANT1, from which you can do PROC TABULATE and make it look any way you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=test;
    class id nova;
    var kcals;
    output out=test1 sum=kcals_sum;
run; 
proc transpose data=test1(where=(_type_ in (1 3))) prefix=nova out=test1a;
    by id;
    id nova;
    var kcals_sum;
run;
data want1;
    merge test1a test1(where=(_type_ in (0 2)));
    by id;
    array nn nova1-nova4;
    array pct pct1-pct4;
    do i=1 to dim(nn);
        pct(i)=nn(i)/kcals_sum;
    end;
    drop _type_ _freq_ _name_ i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 18:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841952#M36504</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-01T18:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Adding total row or function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841960#M36505</link>
      <description>&lt;P&gt;Your example shows making 4 sets from one where you intentionally exclude variables. Is your real data something where you want to add the "Nova" back from a case where each data set is supposed to be from one "nova"? Or are you actually doing all of that to your existing data?&lt;/P&gt;
&lt;P&gt;Is the purpose of this to make the output data set from tabulate? The output structure of the data set is still very likely to require post processing as that is just the nature of the output sets created by tabulate.&lt;/P&gt;
&lt;P&gt;Perhaps you shouldn't be using tabulate at all but you have not managed to describe what it is that you actually want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suggestion: Show what you expect the final result of this to look like. Or at least a representation with indications of what goes into the report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 19:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841960#M36505</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-01T19:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Adding total row or function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841971#M36506</link>
      <description>&lt;P&gt;Hi, I would want something like this (see below), but as a dataset output and not results (only the "all participants" percentage would be actually needed here):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc tabulate data=test;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;class id nova;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;var kcals;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;table id all='All participants',&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(nova all='Total calories per participant')*&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;kcals=' '*(sum='Total calories' rowpctsum='Percentage')&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/ misstext=' ';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SJ12_0-1667331525590.png" style="width: 466px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76854i31C6C6A80B55706A/image-dimensions/466x147?v=v2" width="466" height="147" role="button" title="SJ12_0-1667331525590.png" alt="SJ12_0-1667331525590.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;OR something that would just indicate: % of kcals from Nova 4 for all participants as a result, for example.&lt;/P&gt;&lt;P&gt;The reason why I didn’t do the proc tabulate directly is because I needed to delete participants that have consumed 0 kcals in total (total of 0 per id) (I don't want their total to be included in the average), explaining why I used that synthax.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 19:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841971#M36506</guid>
      <dc:creator>SJ12</dc:creator>
      <dc:date>2022-11-01T19:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Adding total row or function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841976#M36507</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The reason why I used the longer synthax is because I wanted to delete participants that have consumed 0 kcals in total (total of 0 per id). I don't want their total to be included in the average when calculating percentages.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As to the result I want, you can see my reply to ballardw. Thanks!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 19:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841976#M36507</guid>
      <dc:creator>SJ12</dc:creator>
      <dc:date>2022-11-01T19:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Adding total row or function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841993#M36508</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/425348"&gt;@SJ12&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I would want something like this (see below), but as a dataset output and not results (only the "all participants" percentage would be actually needed here):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data=test;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;class id nova;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;var kcals;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;table id all='All participants',&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(nova all='Total calories per participant')*&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;kcals=' '*(sum='Total calories' rowpctsum='Percentage')&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/ misstext=' ';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SJ12_0-1667331525590.png" style="width: 466px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76854i31C6C6A80B55706A/image-dimensions/466x147?v=v2" width="466" height="147" role="button" title="SJ12_0-1667331525590.png" alt="SJ12_0-1667331525590.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;OR something that would just indicate: % of kcals from Nova 4 for all participants as a result, for example.&lt;/P&gt;
&lt;P&gt;The reason why I didn’t do the proc tabulate directly is because I needed to delete participants that have consumed 0 kcals in total (total of 0 per id) (I don't want their total to be included in the average), explaining why I used that synthax.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now, provide the names of every single variable that should be in output. You cannot have repeats of names, so "total calories" , "percentage" ,"1","2","3","4" .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And provide an example data set that we can test code with. I believe this has been asked multiple times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF you have ID with 0 kcals, then set them to missing. Then there is nothing to "sum" and would not get included in the percent calculations.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 22:08:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/841993#M36508</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-01T22:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Adding total row or function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/842050#M36509</link>
      <description>&lt;P&gt;Lots of questions. The reason I ask is because it seems like you are working very hard to do something, and I'm sure there are easier methods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;What is wrong with the data set I provided earlier, which I named WANT1? It looks to me like this is EXACTLY what you are asking for, except for item #2 below, and that the columns are in a different order (which is easily fixed).&lt;/LI&gt;
&lt;LI&gt;Surely you know that an Excel file is not a SAS data set, we cannot produce a SAS data set that has variables named 1 or 2 or 3 or 4, SAS variable names cannot begin with a number, and there can't be sub-columns named Total Calories and Percentage; sub-columns don't exist in SAS. So in the SAS data set that you say you want, what should the variables be named?&lt;/LI&gt;
&lt;LI&gt;You say you want this as an output data set, but its rarely a good idea to ask for a wide data set (especially when it looks like you want a report, despite what you said). What would you do with this SAS data set (what analysis, what further computations, what report) will you do with this wide data set?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please do not ignore any of the above. Explain each item above.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 11:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/842050#M36509</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-02T11:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adding total row or function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/842121#M36510</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I never said there was something wrong with the data set WANT1. I just didn’t mind keeping the longer synthax, since I understood well every step of it and because I wanted to make sure that participants with a total of 0 kcals were deleted and weren’t taken in account in the average. Which line in the data set WANT1 takes that into account?&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;“there can't be sub-columns named Total Calories and Percentage; sub-columns don't exist in SAS”. Not sure I understand here. I thought they existed since we are able to obtain those columns through proc tabulate?&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This is what I want (have the total % for each nova category):&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SJ12_0-1667404023431.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76873iD673699DB3010884/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SJ12_0-1667404023431.png" alt="SJ12_0-1667404023431.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I want what is above. I just wanted to have the totals first and THEN be able to calculate different percentages from that data set, instead of having them directly in the original data set. I just wanted to have 2 steps for it. My boss asked to do it this way.&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Hope it’s more clear. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 15:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/842121#M36510</guid>
      <dc:creator>SJ12</dc:creator>
      <dc:date>2022-11-02T15:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Adding total row or function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/842123#M36511</link>
      <description>&lt;P&gt;Hi, the data set was provided in the question. Here is it again:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;data test;&lt;/DIV&gt;&lt;DIV&gt;input id foodtype $ Nova $ Subnova $ kcals;&lt;/DIV&gt;&lt;DIV&gt;datalines;&lt;/DIV&gt;&lt;DIV&gt;001 butter 1 oils 10&lt;/DIV&gt;&lt;DIV&gt;001 fish 2 protein 15&lt;/DIV&gt;&lt;DIV&gt;001 banana 3 fruit 10&lt;/DIV&gt;&lt;DIV&gt;001 cherry 4 fruit 25&lt;/DIV&gt;&lt;DIV&gt;002 burger 2 frozen 5&lt;/DIV&gt;&lt;DIV&gt;002 pumpkin 2 other 4&lt;/DIV&gt;&lt;DIV&gt;002 carrot 3 veg 6&lt;/DIV&gt;&lt;DIV&gt;003 apple 1 fruit 100&lt;/DIV&gt;&lt;DIV&gt;003 tahini 4 &amp;nbsp; spread &amp;nbsp; 60&lt;/DIV&gt;&lt;DIV&gt;004 . &amp;nbsp; . &amp;nbsp; &amp;nbsp;. &amp;nbsp; 0&lt;/DIV&gt;&lt;DIV&gt;005 burger &amp;nbsp;2 &amp;nbsp;frozen &amp;nbsp;13&lt;/DIV&gt;&lt;DIV&gt;005 ceral &amp;nbsp;3 grain 56&lt;/DIV&gt;&lt;DIV&gt;005 milk &amp;nbsp;1 &amp;nbsp;prod 35&lt;/DIV&gt;&lt;DIV&gt;005 vinegar 4 &amp;nbsp;Other &amp;nbsp;100&lt;/DIV&gt;&lt;DIV&gt;006 . &amp;nbsp; &amp;nbsp;. &amp;nbsp; . &amp;nbsp; 0&lt;/DIV&gt;&lt;DIV&gt;006 vinegar 4 &amp;nbsp;Other &amp;nbsp;100&lt;/DIV&gt;&lt;DIV&gt;;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is an example of what I want (see below). I want to have the % of consumption of "Nova 4'' among all participants. I thought I mentioned this already, but maybe it's not clear since I'm new to SAS. Let me know if that's the case. Thanks&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-11-02 at 11.49.36 AM.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76874iE008F19EC4FB7756/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2022-11-02 at 11.49.36 AM.png" alt="Screen Shot 2022-11-02 at 11.49.36 AM.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 02 Nov 2022 15:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-total-row-or-function/m-p/842123#M36511</guid>
      <dc:creator>SJ12</dc:creator>
      <dc:date>2022-11-02T15:51:13Z</dc:date>
    </item>
  </channel>
</rss>

