<?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: Expansion from rows to columns? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252439#M47904</link>
    <description>&lt;P&gt;Try this (tested):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data letters;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; input Variable1 Variable2 $ Variable3 $5.;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; datalines;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1 W 3.2&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1 X 5.1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2 X 7.0&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;3 E 8.9&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;3 W 1.3&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;data nodup;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set letters;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; by variable1;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if first.variable1=1 then output;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data dup;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set letters;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; by variable1;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if first.variable1=0 then output;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; rename variable2=Variable4 variable3=Variable5;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;data nodup_dup;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; merge nodup dup;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; by variable1;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if variable4="" then variable4="NULL";&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if variable5="" then variable5="NULL";&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Feb 2016 17:27:17 GMT</pubDate>
    <dc:creator>lxn1021</dc:creator>
    <dc:date>2016-02-25T17:27:17Z</dc:date>
    <item>
      <title>Expansion from rows to columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252153#M47788</link>
      <description>&lt;P&gt;Hi SAS users, I have a dataset as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;Variable1 &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Variable2 &amp;nbsp; &amp;nbsp;Variable3 &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;W&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.2&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;5.1&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7.0&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;E &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8.9&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;W &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.3&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Whenever, the Variable2 corresponding to Variable1 (ID) is changing its value, I&amp;nbsp;would like to expand it to new columns. In fact per each new category (based on Variable2), two new columns are added to the right:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;Variable1 &amp;nbsp;&amp;nbsp;Variable2 &amp;nbsp; &amp;nbsp;Variable3 &amp;nbsp;&amp;nbsp;Variable4 &amp;nbsp;&amp;nbsp;Variable5&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;W &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5.1&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7.0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; null &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;null&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;E &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8.9 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; W &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.3&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;PURPOSE: At the end, I&amp;nbsp;am&amp;nbsp;interested to have a unique Variable1 in first column; and the corresponding category(ies) are expanded to the right instead of stacking on top of eachother.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;Could you please help how to do it?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 19:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252153#M47788</guid>
      <dc:creator>almmotamedi</dc:creator>
      <dc:date>2016-02-24T19:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Expansion from rows to columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252155#M47789</link>
      <description>&lt;P&gt;You've asked the question here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/How-to-expand-columns-in-a-dataset/m-p/252081#M47754" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-to-expand-columns-in-a-dataset/m-p/252081#M47754&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And had several suggestions and links to solutions. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there something specific that you're having issues with? Or do you want an exact solution to exactly your problem with full code?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 19:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252155#M47789</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-24T19:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Expansion from rows to columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252193#M47799</link>
      <description>&lt;P&gt;None of those "And had several suggestions and links to solutions." were useful.&lt;BR /&gt;&lt;BR /&gt;By the way, I don't want a full code and exact solution to my problem. I am re-posting my question so that new people/users can easily follow and read my question and give me some hints.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 20:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252193#M47799</guid>
      <dc:creator>almmotamedi</dc:creator>
      <dc:date>2016-02-24T20:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Expansion from rows to columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252231#M47828</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65070"&gt;@almmotamedi&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;None of those "And had several suggestions and links to solutions." were useful.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65070"&gt;@almmotamedi&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can hardly believe that. For example, which of the four techniques from that link I provided in the other thread did you try? What kind of issues did you encounter that you didn't find them useful? I was pretty sure that at least two or three of those solutions&amp;nbsp;could be successfully applied to your data.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 21:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252231#M47828</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-24T21:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Expansion from rows to columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252258#M47846</link>
      <description>&lt;P&gt;Ok questions - please answer as clearly and thoroughly as possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Is it actually only two variables or are there more?&lt;/P&gt;
&lt;P&gt;2. What will be the naming conventions for new variables? Are the old variable names changing?&lt;/P&gt;
&lt;P&gt;3. What is the maximum number of vqriable additions? Are you only adding on 2 new variables? Do you know it in advance or do you have do dynamically figure it out?&lt;/P&gt;
&lt;P&gt;4. Is this a one time job, or do you need to repeat it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5. Post anything you've tried and highlight what issues you're having....there's a point when people start to feel taken advantage of. Posting what you've tried shows that you're asking for help, not for other people to do your work.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 23:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252258#M47846</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-24T23:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Expansion from rows to columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252353#M47871</link>
      <description>&lt;P&gt;Also, motivate why you want to do this? What is the inconvenience&amp;nbsp;of having the data normalized? How do you intend to use the transposed data set?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 12:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252353#M47871</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-02-25T12:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Expansion from rows to columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252439#M47904</link>
      <description>&lt;P&gt;Try this (tested):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data letters;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; input Variable1 Variable2 $ Variable3 $5.;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; datalines;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1 W 3.2&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1 X 5.1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2 X 7.0&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;3 E 8.9&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;3 W 1.3&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;data nodup;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set letters;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; by variable1;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if first.variable1=1 then output;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data dup;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set letters;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; by variable1;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if first.variable1=0 then output;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; rename variable2=Variable4 variable3=Variable5;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;data nodup_dup;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; merge nodup dup;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; by variable1;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if variable4="" then variable4="NULL";&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if variable5="" then variable5="NULL";&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 17:27:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expansion-from-rows-to-columns/m-p/252439#M47904</guid>
      <dc:creator>lxn1021</dc:creator>
      <dc:date>2016-02-25T17:27:17Z</dc:date>
    </item>
  </channel>
</rss>

