<?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 SQL - Ordering Column Names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404428#M98315</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Nice.&amp;nbsp; Though to be fair, it is better to model the data in a way which allows multiple rows per block of data rather than across the page, this is pretty standard in CDISC models for instance.&amp;nbsp; For example this data could be represented:&lt;/P&gt;
&lt;PRE&gt;ID  SEQ  NAME  LAST  AGE
1    1   abc   temp   12
1    2   def   temp2  43
1    3   efg   temp3  34&lt;/PRE&gt;
&lt;P&gt;In this method the information is all present, easy to work with, and is expandable infinitely (almost), whereas columns run out or become unwieldy and coding is far harder.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Of course the way to go. Normalized data is to be preferred. Intelligent data makes for intelligent programs.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Oct 2017 10:52:29 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-10-16T10:52:29Z</dc:date>
    <item>
      <title>Proc SQL - Ordering Column Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404418#M98310</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table that has the below columns...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;Name1&amp;nbsp; &amp;nbsp; &amp;nbsp;Name2&amp;nbsp; &amp;nbsp; &amp;nbsp;Name3&amp;nbsp; &amp;nbsp; &amp;nbsp;Age1&amp;nbsp; &amp;nbsp; &amp;nbsp;Age2&amp;nbsp; &amp;nbsp; &amp;nbsp; Age3&amp;nbsp; &amp;nbsp; &amp;nbsp;Last1&amp;nbsp; &amp;nbsp; &amp;nbsp;Last2&amp;nbsp; &amp;nbsp; &amp;nbsp; Last3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the exception of the column named ID, I would like to re-organise the columns based on number at the end so that I get the below result...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; Name1&amp;nbsp; &amp;nbsp; Age1&amp;nbsp; &amp;nbsp; &amp;nbsp;Last1&amp;nbsp; &amp;nbsp; &amp;nbsp;Name2&amp;nbsp; &amp;nbsp; &amp;nbsp;Age2&amp;nbsp; &amp;nbsp; &amp;nbsp; Last2&amp;nbsp; &amp;nbsp; &amp;nbsp;Name3&amp;nbsp; &amp;nbsp; &amp;nbsp;Age3&amp;nbsp; &amp;nbsp; &amp;nbsp; Last3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used PROC SQL, to just select them in the order I'd like, however I want to know if there is a quicker way that will do it automatically for me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 10:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404418#M98310</guid>
      <dc:creator>CamRutherford</dc:creator>
      <dc:date>2017-10-16T10:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Ordering Column Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404422#M98312</link>
      <description>&lt;P&gt;There isn't a column order function.&amp;nbsp; You could do it something like;&lt;/P&gt;
&lt;PRE&gt;data yourds;&lt;BR /&gt; id=1; Name1="abc"; Name2="def"; Name3="efg"; Age1=12; Age2=43; Age3=34; Last1="temp"; Last2="temp2"; Last3="Temp3";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt; select NAME&lt;BR /&gt; into   :VLIST separated by " "&lt;BR /&gt; from   SASHELP.VCOLUMN&lt;BR /&gt; where  LIBNAME="WORK"&lt;BR /&gt; and    MEMNAME="YOURDS"&lt;BR /&gt; and    NAME ne "ID"&lt;BR /&gt; order by compress(NAME," ","kd"),&lt;BR /&gt;          case upcase(compress(NAME," ","ka")) when "NAME" then 1 when "LAST" then 2 else 3 end;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt; retain &amp;amp;vlist.;&lt;BR /&gt; set yourds;&lt;BR /&gt;run;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Oct 2017 10:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404422#M98312</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-16T10:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Ordering Column Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404424#M98313</link>
      <description>&lt;P&gt;A different take, using &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;'s example data, that will automatically adapt itself to any number of variable groups:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data yourds;
 id=1; Name1="abc"; Name2="def"; Name3="efg"; Age1=12; Age2=43; Age3=34; Last1="temp"; Last2="temp2"; Last3="Temp3";
run;

proc sql;
create table names as select name from dictionary.columns where libname = 'WORK' and memname = 'YOURDS';
quit;

data names;
set names;
x = anydigit(name);
if x &amp;gt; 0 then x = input(substr(name,x),best.);
run;

proc sql noprint;
select name into :varnames separated by ' ' from names order by x;
quit;

data want;
format &amp;amp;varnames;
set yourds;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Oct 2017 10:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404424#M98313</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-16T10:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Ordering Column Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404426#M98314</link>
      <description>&lt;P&gt;Nice.&amp;nbsp; Though to be fair, it is better to model the data in a way which allows multiple rows per block of data rather than across the page, this is pretty standard in CDISC models for instance.&amp;nbsp; For example this data could be represented:&lt;/P&gt;
&lt;PRE&gt;ID  SEQ  NAME  LAST  AGE
1    1   abc   temp   12
1    2   def   temp2  43
1    3   efg   temp3  34&lt;/PRE&gt;
&lt;P&gt;In this method the information is all present, easy to work with, and is expandable infinitely (almost), whereas columns run out or become unwieldy and coding is far harder.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 10:49:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404426#M98314</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-16T10:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Ordering Column Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404428#M98315</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Nice.&amp;nbsp; Though to be fair, it is better to model the data in a way which allows multiple rows per block of data rather than across the page, this is pretty standard in CDISC models for instance.&amp;nbsp; For example this data could be represented:&lt;/P&gt;
&lt;PRE&gt;ID  SEQ  NAME  LAST  AGE
1    1   abc   temp   12
1    2   def   temp2  43
1    3   efg   temp3  34&lt;/PRE&gt;
&lt;P&gt;In this method the information is all present, easy to work with, and is expandable infinitely (almost), whereas columns run out or become unwieldy and coding is far harder.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Of course the way to go. Normalized data is to be preferred. Intelligent data makes for intelligent programs.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 10:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Ordering-Column-Names/m-p/404428#M98315</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-16T10:52:29Z</dc:date>
    </item>
  </channel>
</rss>

