<?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 PROC TRANSPOSE one variable for across multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANSPOSE-one-variable-for-across-multiple-variables/m-p/762338#M241357</link>
    <description>&lt;P&gt;I want to make my data wide format while keeping the count (CNT) and percent (PCT) as columns.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data Have &amp;gt;&amp;gt; Want&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mariko5797_0-1629304529430.png" style="width: 444px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62703iDB5BA8A9BA37279B/image-dimensions/444x112?v=v2" width="444" height="112" role="button" title="mariko5797_0-1629304529430.png" alt="mariko5797_0-1629304529430.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Code Attempted&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;/* attempt 1*/
proc transpose data = CohortA out = CohortA_wide prefix = A_;
 var CNT PCT;
 by VAR;
 id BMI;
run;

/* attempt 2*/
proc transpose data = CohortA out = CohortA_wide prefix = A_;
 by VAR;
 id BMI;
run;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;The issue with attempt 1 is that CNT and PCT become categories within the same column, which is not what I want.&lt;/P&gt;
&lt;P&gt;The issue with attempt 2 is that only CNT is shown.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the only way to PROC TRANSPOSE twice and then merge? Or is there a way with a single PROC TRANSPOSE?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Aug 2021 16:39:37 GMT</pubDate>
    <dc:creator>mariko5797</dc:creator>
    <dc:date>2021-08-18T16:39:37Z</dc:date>
    <item>
      <title>PROC TRANSPOSE one variable for across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANSPOSE-one-variable-for-across-multiple-variables/m-p/762338#M241357</link>
      <description>&lt;P&gt;I want to make my data wide format while keeping the count (CNT) and percent (PCT) as columns.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data Have &amp;gt;&amp;gt; Want&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mariko5797_0-1629304529430.png" style="width: 444px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62703iDB5BA8A9BA37279B/image-dimensions/444x112?v=v2" width="444" height="112" role="button" title="mariko5797_0-1629304529430.png" alt="mariko5797_0-1629304529430.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Code Attempted&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;/* attempt 1*/
proc transpose data = CohortA out = CohortA_wide prefix = A_;
 var CNT PCT;
 by VAR;
 id BMI;
run;

/* attempt 2*/
proc transpose data = CohortA out = CohortA_wide prefix = A_;
 by VAR;
 id BMI;
run;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;The issue with attempt 1 is that CNT and PCT become categories within the same column, which is not what I want.&lt;/P&gt;
&lt;P&gt;The issue with attempt 2 is that only CNT is shown.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the only way to PROC TRANSPOSE twice and then merge? Or is there a way with a single PROC TRANSPOSE?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 16:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-TRANSPOSE-one-variable-for-across-multiple-variables/m-p/762338#M241357</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2021-08-18T16:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TRANSPOSE one variable for across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANSPOSE-one-variable-for-across-multiple-variables/m-p/762342#M241359</link>
      <description>&lt;P&gt;Within PROC TRANSPOSE the only solution is to transpose twice and then merge, or transpose twice, one to a super long format then to a wide format.&lt;/P&gt;
&lt;P&gt;You can do it in a single data step though.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transposing data tutorials:&lt;BR /&gt;Long to Wide:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/&lt;/A&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;Wide to Long:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And sometimes a double transpose is needed for extra wide data sets:&lt;BR /&gt;&lt;A href="https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd" target="_blank"&gt;https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd&lt;/A&gt;&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/311553"&gt;@mariko5797&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to make my data wide format while keeping the count (CNT) and percent (PCT) as columns.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data Have &amp;gt;&amp;gt; Want&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mariko5797_0-1629304529430.png" style="width: 444px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62703iDB5BA8A9BA37279B/image-dimensions/444x112?v=v2" width="444" height="112" role="button" title="mariko5797_0-1629304529430.png" alt="mariko5797_0-1629304529430.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Code Attempted&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;/* attempt 1*/
proc transpose data = CohortA out = CohortA_wide prefix = A_;
 var CNT PCT;
 by VAR;
 id BMI;
run;

/* attempt 2*/
proc transpose data = CohortA out = CohortA_wide prefix = A_;
 by VAR;
 id BMI;
run;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;The issue with attempt 1 is that CNT and PCT become categories within the same column, which is not what I want.&lt;/P&gt;
&lt;P&gt;The issue with attempt 2 is that only CNT is shown.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the only way to PROC TRANSPOSE twice and then merge? Or is there a way with a single PROC TRANSPOSE?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&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>Wed, 18 Aug 2021 16:46:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-TRANSPOSE-one-variable-for-across-multiple-variables/m-p/762342#M241359</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-08-18T16:46:14Z</dc:date>
    </item>
  </channel>
</rss>

