<?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: Hardcoding format after PROC SUMMARY in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/797011#M255808</link>
    <description>Both &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; have hundreds of replies on your account, since neither of you understood what I wanted to say, I think we all agree the problem is not on your side, but on mine. You are right, starting a new thread would be a better idea at this point! Thanks!</description>
    <pubDate>Thu, 17 Feb 2022 19:11:59 GMT</pubDate>
    <dc:creator>PavelD</dc:creator>
    <dc:date>2022-02-17T19:11:59Z</dc:date>
    <item>
      <title>Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796830#M255728</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;imagine a dataset and format like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input my_category $ value;
datalines;
A 1
A 0
A 3
B 7
B 3
B 1
;
run;

proc format ;
value $total_format
other = "T"
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I want to aggregate over my_category, using a custom format (i know, in this simple example I could simply remove my_category from CLASS, but I need to have the column my_category = T in the output dataset).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I use proc summary:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc summary nway data = have;
class my_category;
var value;

format my_category $total_format.;

output out = have_summed sum = ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;this produces:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;my_category _TYPE_ _FREQ_ value
T           1      6      15&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;This is expected, so far so good. However, my_category retains the format $total_format, instead of... hardcoding it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That means that if you remove the format with the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have2;
set have_summed;
format my_category;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;the result is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;my_category _TYPE_ _FREQ_ value
A           1      6      15&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;i.e. "A" instead of "T", which is simply wrong!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In have_summed, the column my_category appears to have the value "T".&lt;/P&gt;&lt;P&gt;If you export&amp;nbsp;have_summed to a CSV, the formatted value "T" is retained. But if you use for example the CATS/CATX function with my_category, it does not use "T" but "A", i.e. the unformatted value. I find this very confusing. What am I missing? Is there a better way?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Platform SAS 9.4.7.0.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 10:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796830#M255728</guid>
      <dc:creator>PavelD</dc:creator>
      <dc:date>2022-02-17T10:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796838#M255731</link>
      <description>&lt;P&gt;It's not clear what you are trying to do in the last step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;the result is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;my_category _TYPE_ _FREQ_ value
A           1      6      15&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;i.e. "A" instead of "T", which is simply wrong!&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;but this is correct. Formatting doesn't change the underlying value. So when you remove the format, the underlying value is returned. Your earlier run of PROC SUMMARY puts all the value of &lt;FONT face="courier new,courier"&gt;my_category&lt;/FONT&gt; into one category which appears as "T" and the underlying value (unformatted) is the value of "A" (which is what PROC SUMMARY does when it combines categories, it uses the first value alphabetically or numerically to represent combined categories).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what are you trying to do here?&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>Thu, 17 Feb 2022 12:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796838#M255731</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-17T12:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796845#M255737</link>
      <description>&lt;P&gt;To get the formatted values as raw values in a dataset, reroute the output to a dataset with ODS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input my_category $ value;
datalines;
A 1
A 0
A 3
B 7
B 3
B 1
;

proc format ;
value $total_format
other = "T"
;
run;

ods output summary=have2;

proc means nway data=have sum;
class my_category;
var value;
format my_category $total_format.;
run;

ods output close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: forget this; SAS still uses a raw value and the format for the ODS OUTPUT dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 12:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796845#M255737</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-17T12:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796846#M255738</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, thanks for your answer.&lt;/P&gt;&lt;P&gt;I find it hard to believe that when aggregating over values, proc summary takes the first value as a label. I cannot think of a situation where that can be useful and not misleading...&amp;nbsp; &amp;nbsp;From your comment I understand that is the expected behaviour?&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you look at the last dataset, you see that the total for category "A" is 15. That is wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would not care as much and simply keep using the formatted value, except that in some procedures or functions SAS takes the formatted values, sometimes&amp;nbsp; the unformatted value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is really to force the proc summary to use the format only once in the aggregation, not to assign it permanently to the variable while keeping the unformatted values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like the put function in a data step:&lt;/P&gt;&lt;P&gt;new_var = put(other_var, $my_format.);&lt;/P&gt;&lt;P&gt;In this case new_var is not assigned permanently $my_format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe my whole approach is not SAS-y enough, maybe there is a better way. I just cant think of any simple way...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 12:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796846#M255738</guid>
      <dc:creator>PavelD</dc:creator>
      <dc:date>2022-02-17T12:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796847#M255739</link>
      <description>&lt;P&gt;In stead of&lt;/P&gt;
&lt;PRE&gt;data have2;
set have_summed;
format my_category;
run;&lt;/PRE&gt;
&lt;P&gt;you can try something like&lt;/P&gt;
&lt;PRE&gt;data have2;
   set have_summed;
   my_category = put(my_category, $total_format.);
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Feb 2022 12:15:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796847#M255739</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2022-02-17T12:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796848#M255740</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215262"&gt;@PavelD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, thanks for your answer.&lt;/P&gt;
&lt;P&gt;I find it hard to believe that when aggregating over values, proc summary takes the first value as a label. I cannot think of a situation where that can be useful and not misleading...&amp;nbsp; &amp;nbsp;From your comment I understand that is the expected behaviour?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What should PROC SUMMARY call a combined group? Well, anyway, yes, it picks the first value alphabetically or numerically in the combined group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;When you look at the last dataset, you see that the total for category "A" is 15. That is wrong.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Actually, your idea of assigning formats and removing them is causing SAS to say "A" has 15. SAS does what you tell it to do. So its not SAS that's wrong, it's your method that causes the wrong answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&lt;SPAN&gt;What I want is really to force the proc summary to use the format only once in the aggregation, not to assign it permanently to the variable while keeping the unformatted values.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So, when it does this to do the aggregation, what value should it assign to my_category? I'm really not following what you want here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, let's move away from the actual code for a second and explain the analysis you are trying to do from a higher level, with no discussion of code. You have data, you want a certain result, what is that desired result (without mentioning code)? Show us the desired result.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 12:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796848#M255740</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-17T12:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796849#M255741</link>
      <description>&lt;P&gt;you can hardcode any format by using the &lt;STRONG&gt;&lt;EM&gt;vvalue&lt;/EM&gt;&lt;/STRONG&gt; function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;format temp $total_format.;&lt;/P&gt;
&lt;P&gt;temp=value;&lt;/P&gt;
&lt;P&gt;new_cat=vvalue(temp);&lt;/P&gt;
&lt;P&gt;run;&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>Thu, 17 Feb 2022 12:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796849#M255741</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-02-17T12:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796851#M255742</link>
      <description>&lt;P&gt;Thanks Kurt, but in fact the format is maintained in have2 (i.e. the "T" is still not raw):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Image 2022-02-17 001.png" style="width: 176px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68576i3C53E0B11F86786B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image 2022-02-17 001.png" alt="Image 2022-02-17 001.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 12:24:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796851#M255742</guid>
      <dc:creator>PavelD</dc:creator>
      <dc:date>2022-02-17T12:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796853#M255743</link>
      <description>&lt;P&gt;SAS retains the raw value because the variable will also retain its type, so if your category was numeric, but formatted to character values, the formatted values would not be possible:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input my_category value;
datalines;
1 1
1 0
1 3
2 7
2 3
2 1
;

proc format ;
value total_format
other = "T"
;
run;

proc means nway data=have sum;
class my_category;
var value;
format my_category total_format.;
output out=want sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;my_category in WANT is numeric, so the format is needed, and the lowest numeric value for the group is kept.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 12:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796853#M255743</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-17T12:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796854#M255744</link>
      <description>&lt;P&gt;For reasons already stated, using a PUT with the format instead of removing the format is the way to go.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 12:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796854#M255744</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-17T12:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796855#M255745</link>
      <description>&lt;P&gt;I already found that and edited my post accordingly. I let myself be deceived by appearances.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 12:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796855#M255745</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-17T12:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796857#M255747</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;&lt;SPAN&gt;In addition, let's move away from the actual code for a second and explain the analysis you are trying to do from a higher level, with no discussion of code. You have data, you want a certain result, what is that desired result (without mentioning code)? Show us the desired result.&lt;/SPAN&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Good point, I should have started with this in the first place. I appreciate your patience,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;and others.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe my choice of procs will turn out to be wrong completely.&lt;/P&gt;&lt;P&gt;So, I have raw data, let's say 10 columns, of which one is numeric (the VAR in proc summary). Of this raw data I need to create dozens of partially aggregated datasets, using predefined set of custom formats which I apply to 2-4 columns each time. I need to maintain the structure of the raw dataset, i.e. the 9+1 columns, so I put all 9 in the CLASS. My other idea was that I could have did some remerging after proc summary but I did not like that option, I always try to look for the simplest option. So now I have dozens of aggregated datasets, since they all have the same structure, I wanted to SET them together and create a single dataset, but that failed completely because each dimension adopted the zombie format from the first SET dataset, and as I wrote above the formats differed in each aggregation. Ultimately I wanted to export it into CSV, so I simply exported dozens of CSVs instead of one. This worked.&amp;nbsp;What I meant was that in my situation, it would simply be easier to hardcode formats after each aggregation, perhaps with VVALUE as another member suggested, I thought about that, but I was just hoping there is a neater, cleaner option. If you have any idea or general remarks, I am all ears. Thanks!!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 12:46:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796857#M255747</guid>
      <dc:creator>PavelD</dc:creator>
      <dc:date>2022-02-17T12:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796858#M255748</link>
      <description>&lt;P&gt;I'm sure that PROC SUMMARY could work here, but I'm still not clear what you want (for example, I don't understand what you mean by partially aggregated data sets) and again I request that you SHOW ME the desired output.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 12:50:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796858#M255748</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-17T12:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796884#M255759</link>
      <description>&lt;P&gt;If you want PROC SUMMARY to convert formatted values to character using value-labels you can add the multilabel-format option MLF to the class statement;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input my_category $ value;
datalines;
A 1
A 0
A 3
B 7
B 3
B 1
;
run;

proc format ;
   value $total_format other="Total";
   quit;
proc summary nway data = have;
   class my_category / mlf;
   var value;
   format my_category $total_format.;
   output out=have_summed sum=;
   run;
proc contents varnum;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 255px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68583i33084F45101F7AA2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 14:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796884#M255759</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2022-02-17T14:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796886#M255760</link>
      <description>Very weird trick, but it indeed works &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; Thank you</description>
      <pubDate>Thu, 17 Feb 2022 14:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796886#M255760</guid>
      <dc:creator>PavelD</dc:creator>
      <dc:date>2022-02-17T14:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796887#M255761</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, I am sorry I cannot provide more details, nor the desired result, I think it would be a lots of tables and I dont think it would bring much value. Thanks for your help!!</description>
      <pubDate>Thu, 17 Feb 2022 14:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796887#M255761</guid>
      <dc:creator>PavelD</dc:creator>
      <dc:date>2022-02-17T14:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796888#M255762</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215262"&gt;@PavelD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, I am sorry I cannot provide more details, nor the desired result, I think it would be a lots of tables and I dont think it would bring much value. Thanks for your help!!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You could show us the desired output for your example that your provided. But you haven't done that.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 14:45:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796888#M255762</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-17T14:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796889#M255763</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215262"&gt;@PavelD&lt;/a&gt; I'm not able to follow your description of the ultimate goal. My fault not yours.&amp;nbsp; If you would start a new tread using the have/need scenario I expect you to get many excellent answers that may or may not involve PROC SUMMARY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215262"&gt;@PavelD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&lt;SPAN&gt;In addition, let's move away from the actual code for a second and explain the analysis you are trying to do from a higher level, with no discussion of code. You have data, you want a certain result, what is that desired result (without mentioning code)? Show us the desired result.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good point, I should have started with this in the first place. I appreciate your patience,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;and others.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe my choice of procs will turn out to be wrong completely.&lt;/P&gt;
&lt;P&gt;So, I have raw data, let's say 10 columns, of which one is numeric (the VAR in proc summary). Of this raw data I need to create dozens of partially aggregated datasets, using predefined set of custom formats which I apply to 2-4 columns each time. I need to maintain the structure of the raw dataset, i.e. the 9+1 columns, so I put all 9 in the CLASS. My other idea was that I could have did some remerging after proc summary but I did not like that option, I always try to look for the simplest option. So now I have dozens of aggregated datasets, since they all have the same structure, I wanted to SET them together and create a single dataset, but that failed completely because each dimension adopted the zombie format from the first SET dataset, and as I wrote above the formats differed in each aggregation. Ultimately I wanted to export it into CSV, so I simply exported dozens of CSVs instead of one. This worked.&amp;nbsp;What I meant was that in my situation, it would simply be easier to hardcode formats after each aggregation, perhaps with VVALUE as another member suggested, I thought about that, but I was just hoping there is a neater, cleaner option. If you have any idea or general remarks, I am all ears. Thanks!!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 14:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796889#M255763</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2022-02-17T14:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796891#M255765</link>
      <description>&lt;P&gt;Perhaps you should remove NWAY from the PROC SUMMARY statement.&amp;nbsp; If you do that, you will still get exactly what you have now, plus one additional record that aggregates over the entire data set.&amp;nbsp; To identify that additional record, look for _TYPE_=0.&amp;nbsp; (As you know by know, all your current records have _TYPE_=1.)&amp;nbsp; On that _TYPE_=0 record, MY_CATEGORY will have a missing value.&amp;nbsp; So you can get all the numbers you want in one data set, with a small amount of relabeling needed.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 14:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796891#M255765</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-02-17T14:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoding format after PROC SUMMARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796895#M255767</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215262"&gt;@PavelD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Very weird trick, but it indeed works &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; Thank you&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not so weird maybe when you think about how multilabel formats work.&amp;nbsp; The is no way to use the values when they appear multiple times only labels are unique.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 255px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68584i02BD80905FBDF0C6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input my_category $ value @@;
datalines;
A 1 A 0 A 3 B 7 B 3 B 1
;
run;

proc format ;
   value $total_format(multilabel)
      'A','B'="Total 1" 
      'A','B'="Total 2" 
      'A','B'="Total 3" 
      ;
   quit;
proc summary nway data = have;
   class my_category / mlf;
   var value;
   format my_category $total_format.;
   output out=have_summed sum=;
   run;
proc contents varnum;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Feb 2022 15:06:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hardcoding-format-after-PROC-SUMMARY/m-p/796895#M255767</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2022-02-17T15:06:57Z</dc:date>
    </item>
  </channel>
</rss>

