<?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 export data to excel in specific variable order? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-data-to-excel-in-specific-variable-order/m-p/57569#M12423</link>
    <description>Hi,&lt;BR /&gt;
I was able to output the data to csv file. Variable names are not in the file but they are in order I want. Anyone has idea to include variable names? Thanks,&lt;BR /&gt;
&lt;BR /&gt;
%let dataout2=myfile.csv;&lt;BR /&gt;
data _NULL_;&lt;BR /&gt;
set mydata;&lt;BR /&gt;
file "&amp;amp;dataout" DLM=',' LRECL=2000 ;&lt;BR /&gt;
put firstvar secvar ........... lastvar;&lt;BR /&gt;
run;</description>
    <pubDate>Wed, 29 Oct 2008 00:03:38 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-10-29T00:03:38Z</dc:date>
    <item>
      <title>How to export data to excel in specific variable order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-data-to-excel-in-specific-variable-order/m-p/57568#M12422</link>
      <description>Hi,&lt;BR /&gt;
I'll need to export sas data set to excel file. The variable names need to be in a specific order. I used file, put statement to make variable names in the correct order. But once I use proc export, the variables are in alphabet order again. Please help. Thanks,</description>
      <pubDate>Tue, 28 Oct 2008 21:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-data-to-excel-in-specific-variable-order/m-p/57568#M12422</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-28T21:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to export data to excel in specific variable order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-data-to-excel-in-specific-variable-order/m-p/57569#M12423</link>
      <description>Hi,&lt;BR /&gt;
I was able to output the data to csv file. Variable names are not in the file but they are in order I want. Anyone has idea to include variable names? Thanks,&lt;BR /&gt;
&lt;BR /&gt;
%let dataout2=myfile.csv;&lt;BR /&gt;
data _NULL_;&lt;BR /&gt;
set mydata;&lt;BR /&gt;
file "&amp;amp;dataout" DLM=',' LRECL=2000 ;&lt;BR /&gt;
put firstvar secvar ........... lastvar;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 29 Oct 2008 00:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-data-to-excel-in-specific-variable-order/m-p/57569#M12423</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-29T00:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to export data to excel in specific variable order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-data-to-excel-in-specific-variable-order/m-p/57570#M12424</link>
      <description>Well, you already know the names of the variables, so just output them as character strings:&lt;BR /&gt;
&lt;BR /&gt;
%let dataout=myfile.csv;&lt;BR /&gt;
%let varNames=Age,Sex,Height;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
	call symput('varNames2',translate("&amp;amp;VARNAMES"," ",","));&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data _NULL_;&lt;BR /&gt;
set sashelp.class;&lt;BR /&gt;
file "~/&amp;amp;dataout" DLM=',' LRECL=2000 ;&lt;BR /&gt;
if _n_ = 1 then put "&amp;amp;VARNAMES";&lt;BR /&gt;
put &amp;amp;VARNAMES2;&lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Wed, 29 Oct 2008 11:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-data-to-excel-in-specific-variable-order/m-p/57570#M12424</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-10-29T11:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to export data to excel in specific variable order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-data-to-excel-in-specific-variable-order/m-p/57571#M12425</link>
      <description>Just use PROC SQL to order your variables in the order you want, before your PROC EXPORT.&lt;BR /&gt;
&lt;BR /&gt;
[pre]proc sql;&lt;BR /&gt;
  create view EXPORT as&lt;BR /&gt;
  select variale1 as Variable_1&lt;BR /&gt;
       , mysasdata as Start_date format=ddmmyy.&lt;BR /&gt;
       , etc as last_var format=z10.&lt;BR /&gt;
    from mysasdata;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc export.........[/pre]</description>
      <pubDate>Wed, 29 Oct 2008 12:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-data-to-excel-in-specific-variable-order/m-p/57571#M12425</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2008-10-29T12:50:28Z</dc:date>
    </item>
  </channel>
</rss>

