<?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: Proc transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256294#M49093</link>
    <description>What is your desired output? &lt;BR /&gt;And why do you want do this transpose?</description>
    <pubDate>Sat, 12 Mar 2016 15:14:26 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2016-03-12T15:14:26Z</dc:date>
    <item>
      <title>Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256292#M49091</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I'm a new SAS programmer so I'm sorry if I ask you an easy question and I use SAS studio.&lt;/P&gt;&lt;P&gt;I have a dataset made of 3 variables (&lt;SPAN&gt;qtr code id&lt;/SPAN&gt;), I want obtain a dataset with id variable that contains every observations of the input dataset but repeated only once and a number of variables that correspond to the maximum frequency of the id in the input dataset.&lt;/P&gt;&lt;P&gt;I ask you if there is a way to get this output with only one proc transpose and not by using two proc transpose and then merge the output.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is my code but it doesn't produce the desired output.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;data ex.data;&lt;BR /&gt;input id qtr code $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2 A&lt;BR /&gt;2 3 C&lt;BR /&gt;2 1 B&lt;BR /&gt;3 2 A&lt;BR /&gt;4 3 C&lt;BR /&gt;5 1 D&lt;BR /&gt;5 1 A&lt;BR /&gt;6 3 A&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc transpose data=ex.data out=ex.out;&lt;BR /&gt;by id;&lt;BR /&gt;var qtr code;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Alessandro&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 14:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256292#M49091</guid>
      <dc:creator>alep92</dc:creator>
      <dc:date>2016-03-12T14:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256293#M49092</link>
      <description>Can you explain what your desired output would look like, given the sample code you've posted?? Why did you decide on a PROC TRANSPOSE approach? It sounds to me like you want PROC FREQ.&lt;BR /&gt; &lt;BR /&gt;cynthia</description>
      <pubDate>Sat, 12 Mar 2016 15:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256293#M49092</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-03-12T15:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256294#M49093</link>
      <description>What is your desired output? &lt;BR /&gt;And why do you want do this transpose?</description>
      <pubDate>Sat, 12 Mar 2016 15:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256294#M49093</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-03-12T15:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256299#M49095</link>
      <description>&lt;P&gt;The output that I desire look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id &amp;nbsp;qtr1 &amp;nbsp;qtr2 &amp;nbsp;code3 &amp;nbsp;code4&lt;BR /&gt;1 &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&lt;BR /&gt;2 &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;BR /&gt;3 &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&lt;BR /&gt;4 &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&lt;BR /&gt;5 &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;D &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;BR /&gt;6 &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 16:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256299#M49095</guid>
      <dc:creator>alep92</dc:creator>
      <dc:date>2016-03-12T16:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256304#M49096</link>
      <description>&lt;P&gt;Are you guaranteeing only 2 quarters and codes are possible?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 17:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256304#M49096</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-12T17:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256306#M49097</link>
      <description>&lt;P&gt;Also, have you tried he data step method of transposing?&lt;/P&gt;
&lt;P&gt;There's an example here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/modules/longtowide_data.htm" target="_blank"&gt;http://www.ats.ucla.edu/stat/sas/modules/longtowide_data.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 17:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256306#M49097</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-12T17:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256308#M49098</link>
      <description>&lt;P&gt;No there could be more than 2 quarters and codes, it depends on the input dataset.&lt;/P&gt;&lt;P&gt;This happens if in the input dataset there are more than 2 observations with the same id.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 17:19:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256308#M49098</guid>
      <dc:creator>alep92</dc:creator>
      <dc:date>2016-03-12T17:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256312#M49100</link>
      <description>&lt;P&gt;Ok, can you please post some data that's more representative of your structure. Is there a max of 4 quarters for example? Can you end up with duplicate quarters?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a data step of your data by using the techniques illustrated here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank"&gt;http://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You realize that the solution&amp;nbsp;will still likely be at least more than one step? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your original question was:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;I ask you if there is a way to get this output with only one proc transpose and not by using two proc transpose and then merge the output.&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The answer is yes. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, you haven't explained why, which is important. We may end up suggesting solutions that have the same issue, because we don't understand the underlying requirements. That's a waste of everyone's time.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 18:06:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256312#M49100</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-12T18:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256369#M49130</link>
      <description>&lt;P&gt;Yes. This kind of question have been talked about many time. You could search it at this forum and get the answer.&lt;/P&gt;
&lt;P&gt;The simples way is to use proc mean+ idgroup :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data;
input id qtr code $;
datalines;
1 2 A
2 3 C
2 1 B
3 2 A
4 3 C
5 1 D
5 1 A
6 3 A
;
run;

proc sql;
select max(n) into : n
 from (select count(*) as n from data group by id);
quit;
proc summary data=data;
by id;
output out=want idgroup(out[&amp;amp;n] (qtr code)=);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Mar 2016 02:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/256369#M49130</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-13T02:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/316386#M69123</link>
      <description>&lt;P&gt;What an elegant answer! However, the proc sql portion is a bit confusing for me. I will have to put aside some time to truly understand the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Victor&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 20:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/316386#M69123</guid>
      <dc:creator>pkfamily</dc:creator>
      <dc:date>2016-12-02T20:55:14Z</dc:date>
    </item>
  </channel>
</rss>

