<?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: Transpose one variable to create multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677594#M204409</link>
    <description>ID and The IDLABEL option within PROC TRANSPOSE support dynamic naming and labeling.&lt;BR /&gt;Post an example that's reflective of your situation, doesn't need to be real data but more representative it is the better answer you'll get.</description>
    <pubDate>Tue, 18 Aug 2020 19:03:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-08-18T19:03:31Z</dc:date>
    <item>
      <title>Transpose one variable to create multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677547#M204380</link>
      <description>&lt;P&gt;Appereciate if someone of you help me understand to how to the transpose the data based on variable? I just look for the hint.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've a data as below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Value	      Currency	         Segment
795.144,06	EUR	         7183_AC_AS3
804.036,54	EUR	         7183_AC_AS3
842.278,32	EUR	         7183_AC_AS3
817.077,24	EUR	         7183_AC_AS3
&lt;/PRE&gt;
&lt;P&gt;Now I want to&amp;nbsp; create the dataset as below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Currency Segment	Value A	        Value B	       Value C	       Value D
EUR	 7183_AC_AS3	795.144,06	804.036,54	842.278,32	817.077,24
EUR	 7183_AC_AS3	795.144,06	804.036,54	842.278,32	817.077,24
EUR	 7183_AC_AS3	795.144,06	804.036,54	842.278,32	817.077,24
EUR	 7183_AC_AS3	795.144,06	804.036,54	842.278,32	817.077,24
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 16:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677547#M204380</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-08-18T16:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one variable to create multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677551#M204383</link>
      <description>&lt;P&gt;A basic transpose&lt;/P&gt;
&lt;PRE&gt;Proc transpose data=have out=trans;
  by currency segment;
  var value;
run;&lt;/PRE&gt;
&lt;P&gt;(requires input data set to be sorted by currency and segment as usual for BY groups)&lt;/P&gt;
&lt;P&gt;of that data would result in something like:&lt;/P&gt;
&lt;PRE&gt;Currency Segment	Col1	        Col2	       Col3	       Col4
EUR	 7183_AC_AS3	795.144,06	804.036,54	842.278,32	817.077,24
&lt;/PRE&gt;
&lt;P&gt;So why would you need 4 identical rows of values?&lt;/P&gt;
&lt;P&gt;Do you have more than one segment? Would each one of those have exactly 4 values and 4 rows or differing numbers of values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be easy in another data step to create multiple identical rows from that transposed data but there may be some rules you haven't provided yet.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 16:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677551#M204383</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-18T16:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one variable to create multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677554#M204385</link>
      <description>&lt;P&gt;Your example isn't an example of transposing and if you had to do that, it wouldn't be a transpose either. Below are the transpose tutorials I find the most useful for beginners.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transposing data tutorials:&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;Wide to Long:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And sometimes a double transpose is needed for extra wide data sets:&lt;BR /&gt;&lt;A href="https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd" target="_blank"&gt;https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 16:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677554#M204385</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-18T16:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one variable to create multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677562#M204393</link>
      <description>&lt;P&gt;In real like I have multiple variables alongside the provide variables in the initial post. To answer your questions,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So why would you need 4 identical rows of values? &lt;EM&gt;It will not be indentical if I consider the other few variables which I didn't mention in the post.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Do you have more than one segment? &lt;EM&gt;yes, I have more than one Segment in real data&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would each one of those have exactly 4 values and 4 rows or differing numbers of values? &lt;EM&gt;not really, there will be differing numbers of values&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 17:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677562#M204393</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-08-18T17:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one variable to create multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677587#M204406</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;In real like I have multiple variables alongside the provide variables in the initial post. To answer your questions,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So why would you need 4 identical rows of values? &lt;EM&gt;It will not be indentical if I consider the other few variables which I didn't mention in the post. &lt;FONT color="#0000FF"&gt;Then provide a more realistic example including some of the other variables and what role they play in the final output.&lt;/FONT&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Do you have more than one segment? &lt;EM&gt;yes, I have more than one Segment in real data&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would each one of those have exactly 4 values and 4 rows or differing numbers of values? &lt;EM&gt;not really, there will be differing numbers of values. &lt;FONT color="#0000FF"&gt;Provide more realistic example of the data and the matching expected output, include different segments.&lt;/FONT&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Likely what this will resolve to would a transpose similar to the one I show above and then joining that result to your existing data. But we do need to know what the input/output looks like;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 18:27:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677587#M204406</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-18T18:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one variable to create multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677591#M204408</link>
      <description>I want to rename Col1, Col2 variables names with meaningful name as I&lt;BR /&gt;mentioned in the initial post as well.&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Aug 2020 18:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677591#M204408</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-08-18T18:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one variable to create multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677594#M204409</link>
      <description>ID and The IDLABEL option within PROC TRANSPOSE support dynamic naming and labeling.&lt;BR /&gt;Post an example that's reflective of your situation, doesn't need to be real data but more representative it is the better answer you'll get.</description>
      <pubDate>Tue, 18 Aug 2020 19:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677594#M204409</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-18T19:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose one variable to create multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677779#M204507</link>
      <description>&lt;PRE&gt;data x;
input (Value	      Currency	         Segment) ( : $40.);
cards;
795.144,06	EUR	         7183_AC_AS3
804.036,54	EUR	         7183_AC_AS3
842.278,32	EUR	         7183_AC_AS3
817.077,24	EUR	         7183_AC_AS3
;
proc transpose data=x out=temp(drop=_name_);
var value;
run;
data want;
 set x(keep=Currency  Segment);
 if _n_=1 then set temp;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Aug 2020 12:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-one-variable-to-create-multiple-variables/m-p/677779#M204507</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-08-19T12:51:16Z</dc:date>
    </item>
  </channel>
</rss>

