<?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 Denormalizing data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Denormalizing-data/m-p/555792#M154722</link>
    <description>&lt;P&gt;I have data in one format and need to get it to another (nonnormalized) format for manipulation/display purposes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input mycode mytype $1.;
datalines;
111 a
111 b
111 c
222 a
222 b
222 d
222 e
222 f
222 g
333 a
333 q
444 s
555 s
555 e
555 t
666 a
666 b
;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The desired yucky format is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;111 a b c
222 a b d e f g
333 a q
444 s
555 s e t
666 a b&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I know this can be done, but I don't know how to do it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Essentially I think I want to sort by mycode and then do a loop that is:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; for each value of mycode until the last.mycode in each group make mynewtype = mynewtype concatenate mytype on the end&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but obviously I don't know how to translate that into working code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't care whether&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;222 a b d e f g&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;comes out as 7 columns or 2 columns with "a b d e f g" as the value in the second column.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could somebody please point me in the correct direction?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 May 2019 22:26:04 GMT</pubDate>
    <dc:creator>HB</dc:creator>
    <dc:date>2019-05-02T22:26:04Z</dc:date>
    <item>
      <title>Denormalizing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Denormalizing-data/m-p/555792#M154722</link>
      <description>&lt;P&gt;I have data in one format and need to get it to another (nonnormalized) format for manipulation/display purposes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input mycode mytype $1.;
datalines;
111 a
111 b
111 c
222 a
222 b
222 d
222 e
222 f
222 g
333 a
333 q
444 s
555 s
555 e
555 t
666 a
666 b
;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The desired yucky format is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;111 a b c
222 a b d e f g
333 a q
444 s
555 s e t
666 a b&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I know this can be done, but I don't know how to do it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Essentially I think I want to sort by mycode and then do a loop that is:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; for each value of mycode until the last.mycode in each group make mynewtype = mynewtype concatenate mytype on the end&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but obviously I don't know how to translate that into working code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't care whether&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;222 a b d e f g&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;comes out as 7 columns or 2 columns with "a b d e f g" as the value in the second column.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could somebody please point me in the correct direction?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 22:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Denormalizing-data/m-p/555792#M154722</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2019-05-02T22:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Denormalizing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Denormalizing-data/m-p/555794#M154724</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;
data want;
length newx $20.;
set have;
by mycode;
retain newx;
if first.mycode then newx='';
if mytype ne '' then newx=catx(' ',newx,mytype);
if last.mycode;
drop mytype;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 22:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Denormalizing-data/m-p/555794#M154724</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-02T22:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Denormalizing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Denormalizing-data/m-p/555796#M154725</link>
      <description>&lt;P&gt;That results in&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;newx	mycode
a b c	111
a b d e f g	222
a q	333
s	444
s e t	555
a b	666
&lt;/PRE&gt;
&lt;P&gt;which will work just fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;World record response time!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 22:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Denormalizing-data/m-p/555796#M154725</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2019-05-02T22:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Denormalizing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Denormalizing-data/m-p/555797#M154726</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;I don't care whether&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token number"&gt;222&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;a b d e f g&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;comes out as 7 columns or 2 columns with "a b d e f g" as the value in the second column.&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another approach is to use PROC TRANSPOSE, where you can have "the best of both worlds":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input mycode mytype $1.;
datalines;
111 a
111 b
111 c
222 a
222 b
222 d
222 e
222 f
222 g
333 a
333 q
444 s
555 s
555 e
555 t
666 a
666 b
;
run;

proc transpose data=have out=want (drop=_name_);
   by mycode;
   var mytype;
run;

data vwant / view=vwant;
   set want;
   length mytype $100;
   mytype=catx(" ",of col:);
   keep mycode mytype;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;HTH...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 22:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Denormalizing-data/m-p/555797#M154726</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-05-02T22:42:09Z</dc:date>
    </item>
  </channel>
</rss>

