<?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 Change the table format, not transpose though. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604293#M175183</link>
    <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; clnt_label $ cd $;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1234567 740&lt;/P&gt;&lt;P&gt;1234567 750&lt;/P&gt;&lt;P&gt;7654321 760&lt;/P&gt;&lt;P&gt;7654321 780&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope to change the format to :&lt;/P&gt;&lt;P&gt;clnt_label&amp;nbsp;&amp;nbsp; cd1 cd2&lt;/P&gt;&lt;P&gt;1234567&amp;nbsp;&amp;nbsp;&amp;nbsp; 740&amp;nbsp;750&lt;/P&gt;&lt;P&gt;7654321&amp;nbsp;&amp;nbsp;&amp;nbsp; 760 780&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In real word, there are a few hundreds of cd codes and millions of records, is there a good way to transform the table as I hope, thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Nov 2019 21:06:46 GMT</pubDate>
    <dc:creator>pensarchem</dc:creator>
    <dc:date>2019-11-14T21:06:46Z</dc:date>
    <item>
      <title>Change the table format, not transpose though.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604293#M175183</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; clnt_label $ cd $;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1234567 740&lt;/P&gt;&lt;P&gt;1234567 750&lt;/P&gt;&lt;P&gt;7654321 760&lt;/P&gt;&lt;P&gt;7654321 780&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope to change the format to :&lt;/P&gt;&lt;P&gt;clnt_label&amp;nbsp;&amp;nbsp; cd1 cd2&lt;/P&gt;&lt;P&gt;1234567&amp;nbsp;&amp;nbsp;&amp;nbsp; 740&amp;nbsp;750&lt;/P&gt;&lt;P&gt;7654321&amp;nbsp;&amp;nbsp;&amp;nbsp; 760 780&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In real word, there are a few hundreds of cd codes and millions of records, is there a good way to transform the table as I hope, thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604293#M175183</guid>
      <dc:creator>pensarchem</dc:creator>
      <dc:date>2019-11-14T21:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Change the table format, not transpose though.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604294#M175184</link>
      <description>&lt;P&gt;"not transpose though"-- How do i comprehend this? Can you please explain what you mean&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:12:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604294#M175184</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-14T21:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: Change the table format, not transpose though.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604296#M175185</link>
      <description>&lt;P&gt;Never mind, thanks for you attention.&amp;nbsp; Transpose works fine, I misunderstood it..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;transpose&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; clnt_label;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; diagcd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604296#M175185</guid>
      <dc:creator>pensarchem</dc:creator>
      <dc:date>2019-11-14T21:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Change the table format, not transpose though.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604298#M175186</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test;
input clnt_label $ cd $;
datalines;
1234567 740
1234567 750
7654321 760
7654321 780
;
proc sql noprint; 
 select max(obs) into :obs 
from (select count(*) as obs from test group by clnt_label) ;
quit;

proc summary nway data=test missing; 
 class clnt_label; 
 output out = want(drop=_type_ _freq_) 
 idgroup(out[&amp;amp;obs](cd)=) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;/*or*/&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data test;
input clnt_label $ cd $;
datalines;
1234567 740
1234567 750
7654321 760
7654321 780
;

proc transpose data=test out=want(drop=_name_) prefix=cd;
by clnt_label;
var cd;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604298#M175186</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-14T21:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: Change the table format, not transpose though.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604300#M175188</link>
      <description>&lt;P&gt;This IS a transposition.&lt;/P&gt;
&lt;P&gt;First, build the id variable, then transpose:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data pretrans;
set have;
by clnt_label;
if first.clnt_label
then count = 1;
else count + 1;
run;

proc transpose data=pretrans out=want prefix=cd;
by clnt_label;
id count;
var cd;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not tested, as I'm on my tablet.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604300#M175188</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-14T21:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Change the table format, not transpose though.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604301#M175189</link>
      <description>&lt;P&gt;You just need an intermediate step (note: defining a view doesn't create a dataset):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input clnt_label $ cd $;
datalines;
1234567 740
1234567 750
7654321 760
7654321 780
;

data temp / view=temp;
do i = 1 by 1 until(last.clnt_label);
	set test; by clnt_label notsorted;
	output;
	end;
run;

proc transpose data=temp out=want(drop=_name_) prefix=cd;
by clnt_label notsorted;
var cd;
id i;
run;

proc print data=want noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604301#M175189</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-11-14T21:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Change the table format, not transpose though.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604305#M175190</link>
      <description>&lt;P&gt;If you are reading raw data and you always have exactly 2 obs per clnt_label, then :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=dummy);
  input clnt_label $ cd1 $ / dummy $  cd2 $;
datalines;
1234567 740
1234567 750
7654321 760
7654321 780
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you want to convert data set TEST without using proc transpose (but why?), then:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input clnt_label $ cd $;
datalines;
1234567 740
1234567 750
7654321 760
7654321 780
run;
data want (drop=_:);
  do _i=1 by 1 until (last.clnt_label);
    set test (rename=(cd=_cd));
	by clnt_label notsorted;
    array cd {2} $4 ;
    cd{_i}=_cd;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:25:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-table-format-not-transpose-though/m-p/604305#M175190</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-14T21:25:14Z</dc:date>
    </item>
  </channel>
</rss>

