<?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: changing dataset columns to rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572901#M161693</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31988"&gt;@geneshackman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are comfortable using Hashes, It's rather straight forward&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input county	age	data2015	data2016	data2017;
cards;
1	1	89	17	79
1	2	6	76	49
1	3	87	5	25
1	4	45	17	1
1	5	78	59	45
2	1	35	4	20
2	2	51	95	46
2	3	76	24	8
2	4	60	66	30
2	5	54	28	41
;

data _null_;
if _n_=1 then do;
   dcl hash H (ordered: "A") ;
   h.definekey  ("year","county","age") ;
   h.definedata ("county","age","year", "data") ;
   h.definedone () ;
end;
set have end=lr;
array d data2015-data2017;
do i=1 to dim(d);
data=d(i);
year=compress(vname(d(i)),,'kd');
rc=h.add();
end;
if lr then h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NOTE: The solution assumes memory is not a constraint&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2019 19:23:27 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-07-11T19:23:27Z</dc:date>
    <item>
      <title>changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572889#M161689</link>
      <description>&lt;P&gt;I have a data set that looks like this, with data for different years in different columns&lt;/P&gt;
&lt;TABLE width="320" style="width: 240pt; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL width="64" style="width: 48pt;" span="5" /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border: 0px black; border-image: none; width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;county&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD width="64" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;age&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD width="64" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;data2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD width="64" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;data2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD width="64" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;data2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;89&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;17&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;79&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;6&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;76&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;49&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;87&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;25&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;45&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;17&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;78&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;59&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;45&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;35&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;20&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;51&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;95&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;46&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;76&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;24&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;8&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;60&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;66&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;30&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;54&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;28&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;41&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to change this so each year has it's own set of rows, but keeping their county and age, so it would look like this. Is there an easy way to do this?&amp;nbsp; I could read in the data set three times, once for each year, and append each time. But I just wanted to ask if there was an easier way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="256" style="width: 192pt; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL width="64" style="width: 48pt;" span="4" /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border: 0px black; border-image: none; width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;county&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD width="64" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;age&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD width="64" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;year&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD width="64" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;data&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;89&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;6&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;87&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;45&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;78&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;35&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;51&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;76&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;60&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;54&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;17&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;76&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;17&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;59&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;95&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;24&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;66&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2016&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;28&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;79&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;49&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;25&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;45&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;20&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;46&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;8&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;30&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" align="right" style="border: 0px black; border-image: none; height: 15pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2017&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border: 0px black; border-image: none; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;41&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 18:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572889#M161689</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2019-07-11T18:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572891#M161691</link>
      <description>&lt;P&gt;Start with a transpose:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=trans;
by county age;
var data:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then transform the result&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set trans;
year = input(substr(_name_,4),4.);
rename col1=data;
drop _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then you only need to sort according to your needs.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 19:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572891#M161691</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-11T19:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572901#M161693</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31988"&gt;@geneshackman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are comfortable using Hashes, It's rather straight forward&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input county	age	data2015	data2016	data2017;
cards;
1	1	89	17	79
1	2	6	76	49
1	3	87	5	25
1	4	45	17	1
1	5	78	59	45
2	1	35	4	20
2	2	51	95	46
2	3	76	24	8
2	4	60	66	30
2	5	54	28	41
;

data _null_;
if _n_=1 then do;
   dcl hash H (ordered: "A") ;
   h.definekey  ("year","county","age") ;
   h.definedata ("county","age","year", "data") ;
   h.definedone () ;
end;
set have end=lr;
array d data2015-data2017;
do i=1 to dim(d);
data=d(i);
year=compress(vname(d(i)),,'kd');
rc=h.add();
end;
if lr then h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NOTE: The solution assumes memory is not a constraint&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 19:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572901#M161693</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-11T19:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572915#M161698</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31988"&gt;@geneshackman&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;I much prefer the offers by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;because they are dynamic, i.e. not hard coded. To better appreciate their beauty, you can compare them with a sledge-hammer hard-coded frontal attack:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                     
  input county age data2015 data2016 data2017 ; 
  cards ;                                       
1      1      89      17      79                
1      2      6       76      49                
1      3      87       5      25                
1      4      45      17       1                
1      5      78      59      45                
2      1      35       4      20                
2      2      51      95      46                
2      3      76      24       8                
2      4      60      66      30                
2      5      54      28      41                
;                                               
run ;                                           
                                                
data want (keep = county age year data) ;       
  set have (keep = county age data2015 in = d15)
      have (keep = county age data2016 in = d16)
      have (keep = county age data2017)         
  ;                                             
  if d15 then do ;                              
    year =     2015 ;                           
    data = data2015 ;                           
  end ;                                         
  else if d16 then do ;                         
    year =     2016 ;                           
    data = data2016 ;                           
  end ;                                         
  else do ;                                     
    year =     2017 ;                           
    data = data2017 ;                           
  end ;                                         
run ;                                           
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, if you added another piece of data (related to another year), for example, data2018, you'd need to change the code to accommodate it. Also, it requires as many passes through the data as you have data years. The dynamic approaches are devoid of these drawbacks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 19:42:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572915#M161698</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-07-11T19:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572924#M161703</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31988"&gt;@geneshackman&lt;/a&gt;&amp;nbsp;, I may take this opportunity to recommend some books that are priceless to get users to speed in their learning.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp;&lt;SPAN&gt;Book: Data Management Solutions Using SAS® Hash Table Operations: A Business Intelligence Case Study&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best ever.&amp;nbsp; This link has some preview comments -&lt;A href="https://communities.sas.com/t5/Community-Matters/Book-Data-Management-Solutions-Using-SAS-Hash-Table-Operations-A/m-p/433642#M3007" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/Community-Matters/Book-Data-Management-Solutions-Using-SAS-Hash-Table-Operations-A/m-p/433642#M3007&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. For Other approaches, I prefer Ron Cody(quite wholesome)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A sincere request to SAS press&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/14323"&gt;@ShelleySessoms&lt;/a&gt;&amp;nbsp;. I would like to bring to your attention almost everyone whom I met at Citizens seem to be totally unaware of the variety of books(individual topics level by granulairty) offered by SAS press and its details. As a matter of fact, the kind of learning I had at DePaul and the advancement does not parallel but i get paid so I can't complain. lol&amp;nbsp; Consequently, they seem to shy away from application of advance techniques&lt;/P&gt;
&lt;P&gt;While my fellow colleagues have observed my excitement to get them to notice the wealth of knowledge they can get from the books, I would like to ask whether SAS press makes their customers aware of what is available coz it seems the contrary at least here at my CT office.&amp;nbsp; Thank you for your attention.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 20:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572924#M161703</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-11T20:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572927#M161705</link>
      <description>&lt;P&gt;An even more general solution that requires less code is the %untranspose macro that you can download from:&amp;nbsp;&lt;A href="https://github.com/gerhard1050/Untranspose-a-Wide-File" target="_blank"&gt;https://github.com/gerhard1050/Untranspose-a-Wide-File&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using that macro the only code you'd need would be:&lt;/P&gt;
&lt;P&gt;%untranspose(data=have, out=want,by=county age, var=data,id=year)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 20:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572927#M161705</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2019-07-11T20:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572949#M161711</link>
      <description>&lt;P&gt;Perhaps read the data differently to begin with:&lt;/P&gt;
&lt;PRE&gt;data have ;                                     
  input county age @ ; 
  do year = 2015 to 2017;
    input data @;
    output;
  end;
  input;
  cards ;                                       
1      1      89      17      79                
1      2      6       76      49                
1      3      87       5      25                
1      4      45      17       1                
1      5      78      59      45                
2      1      35       4      20                
2      2      51      95      46                
2      3      76      24       8                
2      4      60      66      30                
2      5      54      28      41                
;                                               
run ;   &lt;/PRE&gt;
&lt;P&gt;Proc sort to get the order you want if this doesn't work.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 21:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572949#M161711</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-11T21:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572981#M161727</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;Your code is memory-bound only because you make no assumption that the input file is sorted&amp;nbsp; - which is an advantage if memory is plentiful. Note that the TRANSPOSE solution by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;does rely on the sorted order. If your hash code took advantage of it as well, the hash table memory footprint would be dictated only by the size of the largest group of records by COUNTY. For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                    
  input county age data2015 data2016 data2017 ;
  cards ;                                      
1      1      89      17      79               
1      2      6       76      49               
1      3      87       5      25               
1      4      45      17       1               
1      5      78      59      45               
2      1      35       4      20               
2      2      51      95      46               
2      3      76      24       8               
2      4      60      66      30               
2      5      54      28      41               
;                                              
run ;                                          

data want (keep = county age year data) ;             
  if _n_ = 1 then do ;                                
    dcl hash h (multidata:"Y", ordered:"A") ;         
    h.definekey  ("year") ;                           
    h.definedata ("year", "age", "data") ;            
    h.definedone () ;                                 
    dcl hiter hi ("h") ;                              
  end ;                                               
  do until (last.county) ;                            
    set have ;                                        
    by county ;                                       
    array dd data: ;                                  
    do over dd ;                                      
      year = input (compress (vname (dd),,"kd"), 4.) ;
      data = dd ;                                     
      h.add() ;                                       
    end ;                                             
  end ;                                               
  do while (hi.next() = 0) ;                          
    output ;                                          
  end ;                                               
  h.clear() ;                                         
run ;                                                 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's instructive to see how the task could be approached in the same vein before the advent of the hash object, i.e. using arrays. Obviously, in this case, the array serving in lieu of the hash table should be either sized using a preliminary pass through the data or just made "large enough" (which is what's done below):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep = county age year data) ;           
  do j = 1 by 1 until (last.county) ;               
    set have ;                                      
    by county ;                                     
    array dd (i) data: ;                            
    array tt [0:999, 9999] _temporary_ ;            
    do over dd ;                                    
      tt [0,j] = age ;                              
      tt [i,j] = dd ;                               
    end ;                                           
  end ;                                             
  do over dd ;                                      
    year = input (compress (vname (dd),,"kd"), 4.) ;
    do k = 1 to j ;                                 
      age  = tt [0,k] ;                             
      data = tt [i,k] ;                             
      output ;                                      
    end ;                                           
  end ;                                             
run ;                                               
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With a more dynamic approach, i.e. with pre-sizing the array bounds using a preliminary pass through HAVE, it could look thusly:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* size up array TT */                              
data _null_ ;                                       
  do j = 1 by 1 until (last.county) ;               
    set have end = z ;                              
    by county ;                                     
  end ;                                             
  retain jmax ;                                     
  jmax = jmax max j ;                               
  array dd data: ;                                  
  if z ;                                            
  call symputx ("i", dim (dd)) ;                    
  call symputx ("j", jmax    ) ;                    
run ;                                               
/* execute */                                       
data want (keep = county age year data) ;           
  do j = 1 by 1 until (last.county) ;               
    set have ;                                      
    by county ;                                     
    array dd (i) data: ;                            
    array tt [0:&amp;amp;i, &amp;amp;j] _temporary_ ;               
    do over dd ;                                    
      tt [0,j] = age ;                              
      tt [i,j] = dd ;                               
    end ;                                           
  end ;                                             
  do over dd ;                                      
    year = input (compress (vname (dd),,"kd"), 4.) ;
    do k = 1 to j ;                                 
      age  = tt [0,k] ;                             
      data = tt [i,k] ;                             
      output ;                                      
    end ;                                           
  end ;                                             
run ;                                               
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 01:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/572981#M161727</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-07-12T01:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/573064#M161744</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will pass your message along to the SAS Press folks, and provide your email address should they want to discuss ideas with you for your colleagues at Citizens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for being such a supporter of SAS Press books.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Best,&lt;/P&gt;
&lt;P&gt;Shelley&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 12:34:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/573064#M161744</guid>
      <dc:creator>ShelleySessoms</dc:creator>
      <dc:date>2019-07-12T12:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/573090#M161749</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;
&lt;P&gt;Thanks for the suggestion. Question about the first part&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;transpose&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;have out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token procnames"&gt;trans&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; county age&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;var&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;:&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Where does the var "data" come from? I guess it's the first part of the data2015, data2016, etc? But I get "variable data not found". Does it have to be certain number of letters long, or do the "data2015", "data2016" all have to have exactly the same var name formats?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 13:37:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/573090#M161749</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2019-07-12T13:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/573091#M161750</link>
      <description>&lt;P&gt;If your error messages says that variable DATA was not found then most likely you did not include the colon in the VAR statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var data: ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Jul 2019 13:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/573091#M161750</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-12T13:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/573094#M161752</link>
      <description>&lt;P&gt;"If your error messages says that variable DATA was not found then most likely you did not include the colon in the VAR statement."&lt;/P&gt;
&lt;P&gt;Correct! Oops, early morning, I wasn't looking closely and thought it was a double ;; that I accidentally added. I added the colon and it worked. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 13:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/573094#M161752</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2019-07-12T13:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: changing dataset columns to rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/573098#M161755</link>
      <description>&lt;P&gt;Kurt, just to let you know,&amp;nbsp;your transpose then transform&amp;nbsp;works. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 13:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-dataset-columns-to-rows/m-p/573098#M161755</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2019-07-12T13:55:43Z</dc:date>
    </item>
  </channel>
</rss>

