<?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 sas transpose in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/sas-transpose/m-p/897172#M43766</link>
    <description>&lt;P&gt;i have a dataset in sas&lt;/P&gt;&lt;P&gt;col 1 col 2&amp;nbsp; &amp;nbsp; wk 1&amp;nbsp; &amp;nbsp;w2&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the output to look like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;col 1&amp;nbsp; &amp;nbsp; A1_WK1&amp;nbsp; A1_WK2&amp;nbsp; &amp;nbsp; B1_WK1&amp;nbsp; &amp;nbsp;B2_WK2&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am new to sas just wondering if this is possible&lt;/P&gt;&lt;P&gt;i just want one column to be transposed&lt;/P&gt;</description>
    <pubDate>Wed, 04 Oct 2023 16:34:09 GMT</pubDate>
    <dc:creator>amar8581980</dc:creator>
    <dc:date>2023-10-04T16:34:09Z</dc:date>
    <item>
      <title>sas transpose</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/sas-transpose/m-p/897172#M43766</link>
      <description>&lt;P&gt;i have a dataset in sas&lt;/P&gt;&lt;P&gt;col 1 col 2&amp;nbsp; &amp;nbsp; wk 1&amp;nbsp; &amp;nbsp;w2&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the output to look like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;col 1&amp;nbsp; &amp;nbsp; A1_WK1&amp;nbsp; A1_WK2&amp;nbsp; &amp;nbsp; B1_WK1&amp;nbsp; &amp;nbsp;B2_WK2&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am new to sas just wondering if this is possible&lt;/P&gt;&lt;P&gt;i just want one column to be transposed&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 16:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/sas-transpose/m-p/897172#M43766</guid>
      <dc:creator>amar8581980</dc:creator>
      <dc:date>2023-10-04T16:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: sas transpose</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/sas-transpose/m-p/897174#M43767</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input _col1 $ _col2  $  wk1   wk2;
cards;
A        A1         10      20
A         B1          3     5
;

proc transpose data=have out=temp;
by _col1 _col2;
var wk1 wk2;
run;

proc transpose data=temp delim = _ out=want;
by _col1;
id _col2 _name_;
var col1;
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note I renamed col1 to not interfere with the default output name from PROC TRANSPOSE.&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/450450"&gt;@amar8581980&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i have a dataset in sas&lt;/P&gt;
&lt;P&gt;col 1 col 2&amp;nbsp; &amp;nbsp; wk 1&amp;nbsp; &amp;nbsp;w2&lt;/P&gt;
&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;
&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the output to look like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;col 1&amp;nbsp; &amp;nbsp; A1_WK1&amp;nbsp; A1_WK2&amp;nbsp; &amp;nbsp; B1_WK1&amp;nbsp; &amp;nbsp;B2_WK2&lt;/P&gt;
&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i am new to sas just wondering if this is possible&lt;/P&gt;
&lt;P&gt;i just want one column to be transposed&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 16:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/sas-transpose/m-p/897174#M43767</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-10-04T16:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: sas transpose</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/sas-transpose/m-p/897175#M43768</link>
      <description>&lt;P&gt;Try a double transpose:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have (rename=(col1=id)) out=long;
by id col2;
var wk:;
run;

proc transpose data=long out=want (drop=_name_ rename=(id=col1));
by id;
var col1;
id col1 _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But before you do this, what is the purpose of this wide dataset? Wide datasets are very unwieldy for future analysis, and the wide layout is usually the sign of a report.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 16:45:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/sas-transpose/m-p/897175#M43768</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-04T16:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: sas transpose</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/sas-transpose/m-p/897177#M43769</link>
      <description>&lt;P&gt;Another approach, which in effect is a manual transpose and adding the _name_ which transpose will use to rename the output variables:&lt;/P&gt;
&lt;PRE&gt;data have;
input _col1 $ _col2  $  wk1   wk2;
cards;
A        A1         10      20
A         B1          3     5
;

data helper;
   set have;
   array w(*) wk1 wk2;
   length _name_ $ 32;
   do i=1 to dim(w);
      _name_= catx('_',_col2,vname(w[i]));
      value=w[i];
      output;
   end;
   drop i wk1 wk2;
run;

proc transpose data=helper out=want(drop=_name_);
  by _col1;
  var value;
run;
      &lt;/PRE&gt;
&lt;P&gt;May be of interest if have a more complex naming scheme involved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: Assumes the Have data is actually sorted by _col1 and that the combination of _col2 and the wk variable names will not create duplicates.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 16:54:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/sas-transpose/m-p/897177#M43769</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-04T16:54:32Z</dc:date>
    </item>
  </channel>
</rss>

