<?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: How to create a loop to iterate through columns ? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-loop-to-iterate-through-columns/m-p/85825#M8194</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about proc transpose?&lt;/P&gt;&lt;P&gt;Suppose you want to shove everything into a variable (column) call MYVAR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=have out=want (rename=(col1=myvar)) ;&lt;/P&gt;&lt;P&gt; var _all_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your variables (columns) are all of the same type then you could use a data step with an array;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array old _all_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do over old; myvar=old; output; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; keep myvar;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Jun 2012 16:01:09 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2012-06-18T16:01:09Z</dc:date>
    <item>
      <title>How to create a loop to iterate through columns ?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-loop-to-iterate-through-columns/m-p/85824#M8193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Anyone knows how to write codes for base SAS or SAS EG to do a looping through to iterate all the columns inside the table and then append it into 1 column with many rows ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 07:40:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-loop-to-iterate-through-columns/m-p/85824#M8193</guid>
      <dc:creator>cody_q</dc:creator>
      <dc:date>2012-06-18T07:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a loop to iterate through columns ?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-loop-to-iterate-through-columns/m-p/85825#M8194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about proc transpose?&lt;/P&gt;&lt;P&gt;Suppose you want to shove everything into a variable (column) call MYVAR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=have out=want (rename=(col1=myvar)) ;&lt;/P&gt;&lt;P&gt; var _all_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your variables (columns) are all of the same type then you could use a data step with an array;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array old _all_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do over old; myvar=old; output; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; keep myvar;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 16:01:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-loop-to-iterate-through-columns/m-p/85825#M8194</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-06-18T16:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a loop to iterate through columns ?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-loop-to-iterate-through-columns/m-p/85826#M8195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Transpose is a good idea. However, if you want a single column of data, you must use a BY statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data myView / view=myView;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;obs = _n_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=myView out=want (rename=(col1=value)) ;&lt;/P&gt;&lt;P&gt;by obs;&lt;/P&gt;&lt;P&gt;var _all_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 16:48:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-loop-to-iterate-through-columns/m-p/85826#M8195</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-06-18T16:48:46Z</dc:date>
    </item>
  </channel>
</rss>

