<?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: PROC REPORT / TRANSPOSE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-TRANSPOSE/m-p/887781#M350734</link>
    <description>&lt;P&gt;This should work:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=sale out=sale_t;
    by annee type;
    var var1-var4;
run;

proc report data=sale_t;
    columns _name_ annee,type,col1;
    define _name_/group ' ';
    define annee/across ' ';
    define type/across ' ';
    define col1/sum ' ';
run;
ods html close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a general rule, the wide data set you start with, where repeated values of a variable (in this case VAR) are in different columns, should be avoided. The desired formatting is in data set SALE_T, this is a long (not wide) data set, where repeated values of a variable are in different rows. Using long data sets will make your programming easier, as almost all SAS PROCs are designed to work with long data sets. Please keep this in mind in your future SAS work.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Aug 2023 18:56:02 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-08-03T18:56:02Z</dc:date>
    <item>
      <title>PROC REPORT / TRANSPOSE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-TRANSPOSE/m-p/887775#M350732</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I try to get the following result:&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="sasuser_8_0-1691085974393.png" style="width: 436px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86424iD70A701A17BA5052/image-dimensions/436x91?v=v2" width="436" height="91" role="button" title="sasuser_8_0-1691085974393.png" alt="sasuser_8_0-1691085974393.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from the following table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA SALE;

INPUT ANNEE TYPE $ VAR1 VAR2 VAR3 VAR4;

CARDS;

2020 100 52 36 98 74
2020 200 36 52 2 6 
2021 100 36 55 44 7
2021 200 65 8 24 6
2022 100 6 36 54 8
2022 200 65 8 25 4
;

RUN;&lt;/PRE&gt;&lt;P&gt;I read the following post but it's not exactly the same case:&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Using-proc-report-to-transpose-a-table/m-p/883261" target="_self"&gt;https://communities.sas.com/t5/SAS-Procedures/Using-proc-report-to-transpose-a-table/m-p/883261&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have de solution ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 18:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-TRANSPOSE/m-p/887775#M350732</guid>
      <dc:creator>sasuser_8</dc:creator>
      <dc:date>2023-08-03T18:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT / TRANSPOSE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-TRANSPOSE/m-p/887781#M350734</link>
      <description>&lt;P&gt;This should work:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=sale out=sale_t;
    by annee type;
    var var1-var4;
run;

proc report data=sale_t;
    columns _name_ annee,type,col1;
    define _name_/group ' ';
    define annee/across ' ';
    define type/across ' ';
    define col1/sum ' ';
run;
ods html close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a general rule, the wide data set you start with, where repeated values of a variable (in this case VAR) are in different columns, should be avoided. The desired formatting is in data set SALE_T, this is a long (not wide) data set, where repeated values of a variable are in different rows. Using long data sets will make your programming easier, as almost all SAS PROCs are designed to work with long data sets. Please keep this in mind in your future SAS work.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 18:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-TRANSPOSE/m-p/887781#M350734</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-03T18:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT / TRANSPOSE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-TRANSPOSE/m-p/887783#M350736</link>
      <description>&lt;P&gt;Perhaps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=sale;
   class annee type;
   var var1-var4;
   table (var1-var4)*(max=' '*f=best5.),
         annee=' '*type=' '
         /row=float
   ;
run;
&lt;/PRE&gt;
&lt;P&gt;Proc Tabulate will allow different variables in a column. There might be an issue with what statistic you actually want given a larger data set. Sum might be appropriate as well.&lt;/P&gt;
&lt;P&gt;The ='&amp;nbsp; ' are to suppress default labels. The *f=best5.' after the MAX or other statistic is to set the format. Default with Tabulate would be to include 2 decimal places.&lt;/P&gt;
&lt;P&gt;The table option "row=float is clean up the row labels where the statistic has been suppressed but would leave an apparently empty column otherwise.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Caution with Tabulate: Default behavior is that any observation with a missing value for any of the CLASS variables is to drop the entire observation. So if you have such you need to provide examples in the data and how you expect them to be handled.&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/438581"&gt;@sasuser_8&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I try to get the following result:&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="sasuser_8_0-1691085974393.png" style="width: 436px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86424iD70A701A17BA5052/image-dimensions/436x91?v=v2" width="436" height="91" role="button" title="sasuser_8_0-1691085974393.png" alt="sasuser_8_0-1691085974393.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;from the following table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA SALE;

INPUT ANNEE TYPE $ VAR1 VAR2 VAR3 VAR4;

CARDS;

2020 100 52 36 98 74
2020 200 36 52 2 6 
2021 100 36 55 44 7
2021 200 65 8 24 6
2022 100 6 36 54 8
2022 200 65 8 25 4
;

RUN;&lt;/PRE&gt;
&lt;P&gt;I read the following post but it's not exactly the same case:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Using-proc-report-to-transpose-a-table/m-p/883261" target="_self"&gt;https://communities.sas.com/t5/SAS-Procedures/Using-proc-report-to-transpose-a-table/m-p/883261&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone have de solution ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 18:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-TRANSPOSE/m-p/887783#M350736</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-03T18:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT / TRANSPOSE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-TRANSPOSE/m-p/887809#M350749</link>
      <description>&lt;P&gt;Ok it works as expected.&lt;/P&gt;&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 21:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-TRANSPOSE/m-p/887809#M350749</guid>
      <dc:creator>sasuser_8</dc:creator>
      <dc:date>2023-08-03T21:21:01Z</dc:date>
    </item>
  </channel>
</rss>

