<?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: Panel Data: PROC TRANSPOSE vs ARRAY in DATA STEP in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64577#M18338</link>
    <description>Given the nature of the task, I would vote for the datastep approach to this problem.  Both approaches have room for coding error, thus have to be carefully checked to ensure that you are doing what you intend to do, but the datastep approach, in this case, will run in almost half the time.&lt;BR /&gt;
&lt;BR /&gt;
Similarly, there are many cases where proc summary can be used to transpose data and do it with much less code and quite a bit quicker than proc transpose.&lt;BR /&gt;
&lt;BR /&gt;
On the other hand, as the complexity of the task increases, yes, proc transpose or proc summary can definitely pose less risk than hard coding the solution.&lt;BR /&gt;
&lt;BR /&gt;
Art&lt;BR /&gt;
----------&lt;BR /&gt;
&amp;gt; Hello everyone,&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I have a dataset that I want to transform into a&lt;BR /&gt;
&amp;gt; panel data set. I usually do it in 2 ways: (1)&lt;BR /&gt;
&amp;gt; built-in Proc Transpose, and (2) array in a Data&lt;BR /&gt;
&amp;gt; step. For example,&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; 1st way:&lt;BR /&gt;
&amp;gt; proc sort data=mydata; by isin; run;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; proc transpose data=mydata out=myPaneldata&lt;BR /&gt;
&amp;gt; (rename=(col1=myvar)); &lt;BR /&gt;
&amp;gt; by isin; &lt;BR /&gt;
&amp;gt; var var1-var 500; &lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; 2nd way:&lt;BR /&gt;
&amp;gt; data myPaneldata;&lt;BR /&gt;
&amp;gt; set mydata;&lt;BR /&gt;
&amp;gt; array vars{*} _NUMERIC_;&lt;BR /&gt;
&amp;gt; do k=1 to dim(vars);&lt;BR /&gt;
&amp;gt; myvar=vars{k}; output;&lt;BR /&gt;
&amp;gt; end;&lt;BR /&gt;
&amp;gt; drop k var1-var500;&lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; My question: &lt;BR /&gt;
&amp;gt; - What is the strength and weakness of each method?&lt;BR /&gt;
&amp;gt; - From what I observed repeatedly in several large&lt;BR /&gt;
&amp;gt; datasets I run, it seems that using ARRAY in a data&lt;BR /&gt;
&amp;gt; set is faster? How come? I argue that PROC TRANSPOSE&lt;BR /&gt;
&amp;gt; is a built-in function and for that reason, experts&lt;BR /&gt;
&amp;gt; must have chosen the most efficient, fastest way of&lt;BR /&gt;
&amp;gt; transposing a dataset, and so anything that is not&lt;BR /&gt;
&amp;gt; built-in is 99% of the time slower or at equally fast&lt;BR /&gt;
&amp;gt; but less safe. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Can anyone please advise?</description>
    <pubDate>Wed, 11 May 2011 04:27:00 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2011-05-11T04:27:00Z</dc:date>
    <item>
      <title>Panel Data: PROC TRANSPOSE vs ARRAY in DATA STEP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64576#M18337</link>
      <description>Hello everyone,&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset that I want to transform into a panel data set. I usually do it in 2 ways: (1) built-in Proc Transpose, and (2) array in a Data step. For example,&lt;BR /&gt;
&lt;BR /&gt;
1st way:&lt;BR /&gt;
&lt;B&gt;proc sort data=mydata; by isin; run;&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data=mydata out=myPaneldata (rename=(col1=myvar)); &lt;BR /&gt;
by isin; &lt;BR /&gt;
var var1-var 500; &lt;BR /&gt;
run;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
2nd way:&lt;BR /&gt;
&lt;B&gt;data myPaneldata;&lt;BR /&gt;
set mydata;&lt;BR /&gt;
array vars{*} _NUMERIC_;&lt;BR /&gt;
do k=1 to dim(vars);&lt;BR /&gt;
myvar=vars{k}; output;&lt;BR /&gt;
end;&lt;BR /&gt;
drop k var1-var500;&lt;BR /&gt;
run;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
My question: &lt;BR /&gt;
- What is the strength and weakness of each method?&lt;BR /&gt;
- From what I observed repeatedly in several large datasets I run, it seems that using ARRAY in a data set is faster? How come? I argue that PROC TRANSPOSE is a built-in function and for that reason, experts must have chosen the most efficient, fastest way of transposing a dataset, and so anything that is not built-in is 99% of the time slower or at equally fast but less safe. &lt;BR /&gt;
&lt;BR /&gt;
Can anyone please advise?</description>
      <pubDate>Wed, 11 May 2011 01:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64576#M18337</guid>
      <dc:creator>smilingmelbourne</dc:creator>
      <dc:date>2011-05-11T01:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Panel Data: PROC TRANSPOSE vs ARRAY in DATA STEP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64577#M18338</link>
      <description>Given the nature of the task, I would vote for the datastep approach to this problem.  Both approaches have room for coding error, thus have to be carefully checked to ensure that you are doing what you intend to do, but the datastep approach, in this case, will run in almost half the time.&lt;BR /&gt;
&lt;BR /&gt;
Similarly, there are many cases where proc summary can be used to transpose data and do it with much less code and quite a bit quicker than proc transpose.&lt;BR /&gt;
&lt;BR /&gt;
On the other hand, as the complexity of the task increases, yes, proc transpose or proc summary can definitely pose less risk than hard coding the solution.&lt;BR /&gt;
&lt;BR /&gt;
Art&lt;BR /&gt;
----------&lt;BR /&gt;
&amp;gt; Hello everyone,&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I have a dataset that I want to transform into a&lt;BR /&gt;
&amp;gt; panel data set. I usually do it in 2 ways: (1)&lt;BR /&gt;
&amp;gt; built-in Proc Transpose, and (2) array in a Data&lt;BR /&gt;
&amp;gt; step. For example,&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; 1st way:&lt;BR /&gt;
&amp;gt; proc sort data=mydata; by isin; run;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; proc transpose data=mydata out=myPaneldata&lt;BR /&gt;
&amp;gt; (rename=(col1=myvar)); &lt;BR /&gt;
&amp;gt; by isin; &lt;BR /&gt;
&amp;gt; var var1-var 500; &lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; 2nd way:&lt;BR /&gt;
&amp;gt; data myPaneldata;&lt;BR /&gt;
&amp;gt; set mydata;&lt;BR /&gt;
&amp;gt; array vars{*} _NUMERIC_;&lt;BR /&gt;
&amp;gt; do k=1 to dim(vars);&lt;BR /&gt;
&amp;gt; myvar=vars{k}; output;&lt;BR /&gt;
&amp;gt; end;&lt;BR /&gt;
&amp;gt; drop k var1-var500;&lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; My question: &lt;BR /&gt;
&amp;gt; - What is the strength and weakness of each method?&lt;BR /&gt;
&amp;gt; - From what I observed repeatedly in several large&lt;BR /&gt;
&amp;gt; datasets I run, it seems that using ARRAY in a data&lt;BR /&gt;
&amp;gt; set is faster? How come? I argue that PROC TRANSPOSE&lt;BR /&gt;
&amp;gt; is a built-in function and for that reason, experts&lt;BR /&gt;
&amp;gt; must have chosen the most efficient, fastest way of&lt;BR /&gt;
&amp;gt; transposing a dataset, and so anything that is not&lt;BR /&gt;
&amp;gt; built-in is 99% of the time slower or at equally fast&lt;BR /&gt;
&amp;gt; but less safe. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Can anyone please advise?</description>
      <pubDate>Wed, 11 May 2011 04:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64577#M18338</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-05-11T04:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Panel Data: PROC TRANSPOSE vs ARRAY in DATA STEP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64578#M18339</link>
      <description>Thank you very much. Now I'm aware that there is Proc Summary for the similar purpose, and I will learn how to use it apart from Proc Transpose + Data step array.</description>
      <pubDate>Wed, 11 May 2011 06:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64578#M18339</guid>
      <dc:creator>smilingmelbourne</dc:creator>
      <dc:date>2011-05-11T06:00:33Z</dc:date>
    </item>
    <item>
      <title>Panel Data: PROC TRANSPOSE vs ARRAY in DATA STEP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64579#M18340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For both ways, could say something about how to create panel IDs? thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 02:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64579#M18340</guid>
      <dc:creator>sos</dc:creator>
      <dc:date>2011-11-01T02:00:15Z</dc:date>
    </item>
    <item>
      <title>Panel Data: PROC TRANSPOSE vs ARRAY in DATA STEP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64580#M18341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In my experience with very large data the performance of proc transpose breaks down and becomes highly inefficient in which case data step with array subscript processing becomes more increasingly more efficeint, this is also more sensitive to the number of variables vs. the number of rows.&amp;nbsp; With the number of variables you are dealing with, I have no experienced issues with transpose performance and usually for smaller sets the simplicity of the call outways the small performance difference I experience on my systems.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Nov 2011 17:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Panel-Data-PROC-TRANSPOSE-vs-ARRAY-in-DATA-STEP/m-p/64580#M18341</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-11-02T17:47:26Z</dc:date>
    </item>
  </channel>
</rss>

