<?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: Conversion of a table in SAS in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670202#M23290</link>
    <description>&lt;P&gt;This is called a transpose.&lt;/P&gt;
&lt;P&gt;Transposing data tutorials are here&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;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;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Untested but this should be pretty close.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by startYear variable;
run;

proc transpose data=have out=want;
by startYear;
ID variable;
value Estimate;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338208"&gt;@Tim_sas_&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a very basic question regarding a table where I would like to change the order of rows and columns.&lt;/P&gt;
&lt;P&gt;The problem is illustrated by the picture below. I have a SAS table in the upper format and would like to transform it to the format describes below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would be very glad if some could help me out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Peter&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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pic.JPG" style="width: 611px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47260iB80798CC93262B9E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Pic.JPG" alt="Pic.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jul 2020 20:05:04 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-07-17T20:05:04Z</dc:date>
    <item>
      <title>Conversion of a table in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670201#M23289</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a very basic question regarding a table where I would like to change the order of rows and columns.&lt;/P&gt;&lt;P&gt;The problem is illustrated by the picture below. I have a SAS table in the upper format and would like to transform it to the format describes below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be very glad if some could help me out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peter&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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pic.JPG" style="width: 611px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47260iB80798CC93262B9E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Pic.JPG" alt="Pic.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 19:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670201#M23289</guid>
      <dc:creator>Tim_sas_</dc:creator>
      <dc:date>2020-07-17T19:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of a table in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670202#M23290</link>
      <description>&lt;P&gt;This is called a transpose.&lt;/P&gt;
&lt;P&gt;Transposing data tutorials are here&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;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;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Untested but this should be pretty close.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by startYear variable;
run;

proc transpose data=have out=want;
by startYear;
ID variable;
value Estimate;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338208"&gt;@Tim_sas_&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a very basic question regarding a table where I would like to change the order of rows and columns.&lt;/P&gt;
&lt;P&gt;The problem is illustrated by the picture below. I have a SAS table in the upper format and would like to transform it to the format describes below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would be very glad if some could help me out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Peter&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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pic.JPG" style="width: 611px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47260iB80798CC93262B9E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Pic.JPG" alt="Pic.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 20:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670202#M23290</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-17T20:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of a table in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670204#M23291</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=myData; by startYear variable; run;

proc transpose data=myData out= want(drop=_name_);
by startYear;
var estimate;
id variable;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 20:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670204#M23291</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-07-17T20:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of a table in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670205#M23292</link>
      <description>&lt;P&gt;If all of the values of your Variable are acceptable as SAS variable names this should do it:&lt;/P&gt;
&lt;P&gt;Assumes the data is sorted by startyear. If it isn't sorted then sort before the proc transpose.&lt;/P&gt;
&lt;PRE&gt;Proc transpose data=have 
   out=want;
   by startyear;
   id variable;
   var estimate;
run;&lt;/PRE&gt;
&lt;P&gt;This will however fail of any startyear value has multiple rows with the same value of Variable.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 20:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670205#M23292</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-17T20:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of a table in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670207#M23293</link>
      <description>Thank you very much, this was very helpful!</description>
      <pubDate>Fri, 17 Jul 2020 20:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670207#M23293</guid>
      <dc:creator>Tim_sas_</dc:creator>
      <dc:date>2020-07-17T20:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of a table in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670208#M23294</link>
      <description>Thanks a lot, your code worked excellently. Thank you.</description>
      <pubDate>Fri, 17 Jul 2020 20:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670208#M23294</guid>
      <dc:creator>Tim_sas_</dc:creator>
      <dc:date>2020-07-17T20:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of a table in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670578#M23320</link>
      <description>&lt;P&gt;Could be a job for proc report using across, if you don't need a dataset, but a report.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 08:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conversion-of-a-table-in-SAS/m-p/670578#M23320</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-07-20T08:04:44Z</dc:date>
    </item>
  </channel>
</rss>

