<?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: Variables in specific order in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465559#M118755</link>
    <description>&lt;P&gt;How are performing the Excel output?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;PROC EXPORT&lt;/LI&gt;
&lt;LI&gt;DATA STEP&lt;/LI&gt;
&lt;LI&gt;FILENAME &amp;amp; a PROC&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If Data Step, then you can define the order in the data step - that should be fairly straightforward&lt;/LI&gt;
&lt;LI&gt;Similar for FILENAME/PROC - just use the PROC-specific syntax.&lt;/LI&gt;
&lt;LI&gt;If PROC EXPORT (which is an "all-at-once" step), my suggestion would be to create a view of the source data, define the order of the variables in your view, and then PROC EXPORT the view.&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Tue, 29 May 2018 01:20:18 GMT</pubDate>
    <dc:creator>AndrewHowell</dc:creator>
    <dc:date>2018-05-29T01:20:18Z</dc:date>
    <item>
      <title>Variables in specific order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465552#M118752</link>
      <description>I have a sas dateset which had to be exported in an excel sheet. But the excel output should have columns in a specific order. What can be the best way to order the variables in an specific order?</description>
      <pubDate>Tue, 29 May 2018 01:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465552#M118752</guid>
      <dc:creator>nickspencer</dc:creator>
      <dc:date>2018-05-29T01:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in specific order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465555#M118753</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file="filename.Xlsx";
Proc print data=have; /* or proc report */
    Var a b c d; /* set the variable order here */
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 May 2018 01:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465555#M118753</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-29T01:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in specific order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465558#M118754</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's a few ways, Option 3 is probably the simplest since the order only matters for presentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Option 1: RETAIN&amp;nbsp;statement &lt;STRONG&gt;before&lt;/STRONG&gt; the SET statement.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
retain Age Sex Name Weight Height;
set sashelp.class;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Option 2: PROC SQL with FEEDBACK option and manual reorder&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql feedback;
create table class as
select * from sashelp.class;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Copy the code from the log, reorder the variables and then re-run it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Option 3: Use ODS Excel to PROC PRINT the results and manually control the order there.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file='/folders/myfolders/demo.xlsx';

proc print data=sashelp.class noobs label;
var Name Age Sex Weight Height;
run;

ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/206798"&gt;@nickspencer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I have a sas dateset which had to be exported in an excel sheet. But the excel output should have columns in a specific order. What can be the best way to order the variables in an specific order?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 01:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465558#M118754</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-29T01:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in specific order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465559#M118755</link>
      <description>&lt;P&gt;How are performing the Excel output?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;PROC EXPORT&lt;/LI&gt;
&lt;LI&gt;DATA STEP&lt;/LI&gt;
&lt;LI&gt;FILENAME &amp;amp; a PROC&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If Data Step, then you can define the order in the data step - that should be fairly straightforward&lt;/LI&gt;
&lt;LI&gt;Similar for FILENAME/PROC - just use the PROC-specific syntax.&lt;/LI&gt;
&lt;LI&gt;If PROC EXPORT (which is an "all-at-once" step), my suggestion would be to create a view of the source data, define the order of the variables in your view, and then PROC EXPORT the view.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 29 May 2018 01:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465559#M118755</guid>
      <dc:creator>AndrewHowell</dc:creator>
      <dc:date>2018-05-29T01:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in specific order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465562#M118757</link>
      <description>I am using the proc export</description>
      <pubDate>Tue, 29 May 2018 01:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465562#M118757</guid>
      <dc:creator>nickspencer</dc:creator>
      <dc:date>2018-05-29T01:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in specific order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465564#M118758</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/206798"&gt;@nickspencer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I am using the proc export&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then use one of the other methods.&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 01:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465564#M118758</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-29T01:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in specific order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465568#M118760</link>
      <description>I am looking to use ods and include var in proc print. How do I include sheet name and replace options in ods since I haven’t used it before?</description>
      <pubDate>Tue, 29 May 2018 01:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465568#M118760</guid>
      <dc:creator>nickspencer</dc:creator>
      <dc:date>2018-05-29T01:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in specific order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465569#M118761</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/206798"&gt;@nickspencer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I am looking to use ods and include var in proc print. How do I include sheet name and replace options in ods since I haven’t used it before?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Ok, then use PROC EXPORT. The steps have been explained above.&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 01:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465569#M118761</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-29T01:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in specific order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465582#M118762</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/206798"&gt;@nickspencer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I am looking to use ods and include var in proc print. How do I include sheet name and replace options in ods since I haven’t used it before?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/206798"&gt;@nickspencer&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;ODS EXCEL gives you a lot of control over output into Excel so it's certainly worth learning.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://go.documentation.sas.com/?docsetId=odsug&amp;amp;docsetTarget=p09n5pw9ol0897n1qe04zeur27rv.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://go.documentation.sas.com/?docsetId=odsug&amp;amp;docsetTarget=p09n5pw9ol0897n1qe04zeur27rv.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have specific "How To" usage questions then just Google them. There are quite a few solutions out there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One "downside" with ODS EXCEL: It will always fully re-create the file and you can't update, delete or add a sheet in place.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following code shows how to define a specific sheet name. Replace is not required as it's always gonna be a full create of&amp;nbsp;the whole workbook.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file='c:\temp\test.xlsx' 
  options(autofilter='all' sheet_name='mysheet');

proc print  
  data=sashelp.class(obs=5);
  var Age Name Sex Weight Height;
run;

ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 May 2018 02:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variables-in-specific-order/m-p/465582#M118762</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-29T02:56:56Z</dc:date>
    </item>
  </channel>
</rss>

