<?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 How to transpose array and assign column names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-array-and-assign-column-names/m-p/605582#M175777</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #333333;"&gt;Can anyone advice me how to transpose the following data?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have this data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Claim_ID CODE $5;
datelines;
10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90651 &lt;BR /&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90670 &lt;BR /&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90680 &lt;BR /&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90698 &lt;BR /&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;91170 &lt;BR /&gt;10002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;92405 &lt;BR /&gt;10002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90710 &lt;BR /&gt;10003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90715&lt;BR /&gt;;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to have this data;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Claim_ID&amp;nbsp; Code_1&amp;nbsp;     Code_2&amp;nbsp;    Code_3&amp;nbsp;   Code_4&amp;nbsp;    Code_5

10001&amp;nbsp; &amp;nbsp; &amp;nbsp;90651&amp;nbsp; &amp;nbsp;   90670&amp;nbsp; &amp;nbsp; 90680&amp;nbsp; &amp;nbsp; &amp;nbsp;90698&amp;nbsp; &amp;nbsp; 91170 &amp;nbsp;

10002&amp;nbsp; &amp;nbsp; &amp;nbsp;92405&amp;nbsp; &amp;nbsp; &amp;nbsp;90710&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;

10003&amp;nbsp; &amp;nbsp; &amp;nbsp;90715&lt;BR /&gt;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The number of Code can be more than five per claim but I want to consider the maximum number of distinct Code by claim as my columns.&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Nov 2019 00:29:52 GMT</pubDate>
    <dc:creator>Bikila</dc:creator>
    <dc:date>2019-11-20T00:29:52Z</dc:date>
    <item>
      <title>How to transpose array and assign column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-array-and-assign-column-names/m-p/605582#M175777</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #333333;"&gt;Can anyone advice me how to transpose the following data?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have this data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Claim_ID CODE $5;
datelines;
10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90651 &lt;BR /&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90670 &lt;BR /&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90680 &lt;BR /&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90698 &lt;BR /&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;91170 &lt;BR /&gt;10002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;92405 &lt;BR /&gt;10002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90710 &lt;BR /&gt;10003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90715&lt;BR /&gt;;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to have this data;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Claim_ID&amp;nbsp; Code_1&amp;nbsp;     Code_2&amp;nbsp;    Code_3&amp;nbsp;   Code_4&amp;nbsp;    Code_5

10001&amp;nbsp; &amp;nbsp; &amp;nbsp;90651&amp;nbsp; &amp;nbsp;   90670&amp;nbsp; &amp;nbsp; 90680&amp;nbsp; &amp;nbsp; &amp;nbsp;90698&amp;nbsp; &amp;nbsp; 91170 &amp;nbsp;

10002&amp;nbsp; &amp;nbsp; &amp;nbsp;92405&amp;nbsp; &amp;nbsp; &amp;nbsp;90710&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;

10003&amp;nbsp; &amp;nbsp; &amp;nbsp;90715&lt;BR /&gt;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The number of Code can be more than five per claim but I want to consider the maximum number of distinct Code by claim as my columns.&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 00:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-array-and-assign-column-names/m-p/605582#M175777</guid>
      <dc:creator>Bikila</dc:creator>
      <dc:date>2019-11-20T00:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to transpose array and assign column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-array-and-assign-column-names/m-p/605585#M175778</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/298553"&gt;@Bikila&lt;/a&gt;&amp;nbsp; &amp;nbsp;Are you asking for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Claim_ID CODE :$5.;
datalines;
10001       90651 
10001       90670 
10001       90680 
10001       90698 
10001       91170 
10002       92405 
10002       90710 
10003       90715
;
proc transpose data=have out=want(drop=_name_) prefix=CODE_;
by claim_id;
var code;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Nov 2019 00:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-array-and-assign-column-names/m-p/605585#M175778</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-20T00:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to transpose array and assign column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-array-and-assign-column-names/m-p/605662#M175795</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/298553"&gt;@Bikila&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another way to achieve this using an array (alternatively to the solution posted by&amp;nbsp;&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;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* Put the max number of code_ variables in a macro variable &amp;amp;max_obs -&amp;gt; here it is 5 */

proc sql noprint;
	select max(frequency) into: max_obs from (select count(Claim_ID) as frequency from have group by Claim_ID);
run;

data want;
	set have;
	
	array code_(&amp;amp;max_obs) $;
	
	by claim_id;
	retain code_;
	
 	if first.claim_id then do;
 		counter=0;
 		call missing (of code_(*));
 	end;
 	counter+1;

	do i=1 to dim(code_);
		code_(counter) = code;
	end;
	
	if last.claim_ID then output;
	drop i code counter;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Nov 2019 10:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-array-and-assign-column-names/m-p/605662#M175795</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-11-20T10:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to transpose array and assign column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-array-and-assign-column-names/m-p/615515#M180041</link>
      <description>Thank you! This is exactly how I wanted it.</description>
      <pubDate>Tue, 07 Jan 2020 00:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-array-and-assign-column-names/m-p/615515#M180041</guid>
      <dc:creator>Bikila</dc:creator>
      <dc:date>2020-01-07T00:40:02Z</dc:date>
    </item>
  </channel>
</rss>

