<?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: Assigning Variable Order in PROC EXPORT Statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/431585#M68677</link>
    <description>&lt;P&gt;have you got the order you wanted? can you tell me how you have done?&lt;/P&gt;</description>
    <pubDate>Sun, 28 Jan 2018 09:29:59 GMT</pubDate>
    <dc:creator>YHJ</dc:creator>
    <dc:date>2018-01-28T09:29:59Z</dc:date>
    <item>
      <title>Assigning Variable Order in PROC EXPORT Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/225231#M53912</link>
      <description>&lt;P&gt;I have the PROC EXPORT statement with a KEEP statement in the DATA step, I thought, would simultaneously keep the variables from my data set I want to export and retain them in this order. However, when I run this statement, the variables are not in this order. How do I assign variable order in my EXPORT statement&amp;nbsp;so I don't have to manually reorder them in excel?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC EXPORT 
DATA=Work.Surveytempdata
(keep=Response_ID Response_Status Region_ AnotherOffer Job Q11 Q12 Length_Employment Q14 Q15 Q16 Q17 Q18 Q19 Q20 Q21 Q22 Q23 Q24 TrainingYN Q26 Q27 Q28 Q29 Q30 Q31 Q32 TrainingOther Q33 TrainingTimeframe Q35 TrainingPreparedMe
Q37 Q38 Q39 Q40 Q41 Q42	ChangeTrainingOther WorkloadExpected WorkloadNotExpected Q46 PhysicallyDemanding TooPhysicallyDemanding MostPhysicallyDemanding Q50 WorkingConditions
Q52 Q53 Q54 Q55 WorkingConditionsOther Q56 InfoForJob Q58 Q59 Q60 Q61 InfoForJobOther Q62 ToolsResources Q64 Q65 ToolsResourcesOther Q66 SkillsAbilities Q68
SupervisorCommunication Q70 DignityRespect Q72 WorkAgain Q74 Q75)
OUTFILE='\\SharedDrive\Desktop\survey'
DBMS=xlsx;
label;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Sep 2015 21:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/225231#M53912</guid>
      <dc:creator>CarpeDatum</dc:creator>
      <dc:date>2015-09-11T21:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning Variable Order in PROC EXPORT Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/225235#M53913</link>
      <description>&lt;P&gt;Use a view.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let keep=Response_ID Response_Status Region_ AnotherOffer Job Q11 Q12 Length_Employment Q14 Q15 Q16 Q17 Q18 Q19 Q20 Q21 Q22 Q23 Q24 TrainingYN Q26 Q27 Q28 Q29 Q30 Q31 Q32 TrainingOther Q33 TrainingTimeframe Q35 TrainingPreparedMe
Q37 Q38 Q39 Q40 Q41 Q42	ChangeTrainingOther WorkloadExpected WorkloadNotExpected Q46 PhysicallyDemanding TooPhysicallyDemanding MostPhysicallyDemanding Q50 WorkingConditions
Q52 Q53 Q54 Q55 WorkingConditionsOther Q56 InfoForJob Q58 Q59 Q60 Q61 InfoForJobOther Q62 ToolsResources Q64 Q65 ToolsResourcesOther Q66 SkillsAbilities Q68
SupervisorCommunication Q70 DignityRespect Q72 WorkAgain Q74 Q75;

data surveyV/view=surveyV;
   retain &amp;amp;keep;
   set surveytemp(keep=&amp;amp;keep);
   run;


PROC EXPORT DATA=surveyv OUTFILE='\\SharedDrive\Desktop\survey' DBMS=xlsx;
   label;
   run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2015 15:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/225235#M53913</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-09-14T15:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning Variable Order in PROC EXPORT Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/225354#M53924</link>
      <description>&lt;P&gt;PROC EXPORT examines the dataset and the creates a DATA step that does the real work (you see this in the log)&lt;/P&gt;&lt;P&gt;Any DATA step retains the order of variables as it is in the input dataset, unless you use the variable names before the SET statement in another statement.&lt;/P&gt;&lt;P&gt;eg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA want;&lt;/P&gt;&lt;P&gt;FORMAT&lt;/P&gt;&lt;P&gt;&amp;nbsp; var2&lt;/P&gt;&lt;P&gt;&amp;nbsp; var1&lt;/P&gt;&lt;P&gt;&amp;nbsp; var7&lt;/P&gt;&lt;P&gt;&amp;nbsp; var3&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;SET have;&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;will change the order of the variables so those in the (otherwise empty) FORMAT statement appear first.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your possible solutions are:&lt;/P&gt;&lt;P&gt;reorder the variables as described with a DATA step;&lt;/P&gt;&lt;P&gt;reorder the variables with a CREATE TABLE AS SELECT in PROC SQL&lt;/P&gt;&lt;P&gt;use the code created by PROC EXPORT in a newly created Code window and change the order of variables there&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2015 10:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/225354#M53924</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-09-14T10:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning Variable Order in PROC EXPORT Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/225365#M53925</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__﻿&lt;/a&gt;&amp;nbsp;thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I understand you correctly, you've written a let statement that creates a variable called keep which identifies which variables I want to keep. Then in a data statement, you're creating a variable that invokes keep and retains the variables set in that statement above. Then you are exporting the view with the labels. Is this correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two question:&lt;/P&gt;&lt;P&gt;- Why do you have "keep=" written twice? I've never seen that before.&lt;/P&gt;&lt;P&gt;- When I run the code, it tells me that the view does not exist. Is it because I've created a view from a data set with the same name in the data step?: &amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ERROR: File WORK.SURVEYV.DATA does not exist.&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Sep 2015 13:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/225365#M53925</guid>
      <dc:creator>CarpeDatum</dc:creator>
      <dc:date>2015-09-14T13:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning Variable Order in PROC EXPORT Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/225372#M53926</link>
      <description>&lt;P&gt;The keep=keep= is a typo. Just use %let keep=&lt;EM&gt;var_list&lt;/EM&gt; ;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2015 14:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/225372#M53926</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-09-14T14:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning Variable Order in PROC EXPORT Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/431585#M68677</link>
      <description>&lt;P&gt;have you got the order you wanted? can you tell me how you have done?&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2018 09:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/431585#M68677</guid>
      <dc:creator>YHJ</dc:creator>
      <dc:date>2018-01-28T09:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning Variable Order in PROC EXPORT Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/431590#M68678</link>
      <description>&lt;P&gt;This thread is from &amp;gt; 2 years back.This means that only the few people that participated will see any new entries, thereby massively reducing the number of people that could help you.&lt;/P&gt;
&lt;P&gt;Please post your question in a new thread, with code and data examples.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2018 09:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/431590#M68678</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-28T09:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning Variable Order in PROC EXPORT Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/431779#M68687</link>
      <description>&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 13:44:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-Variable-Order-in-PROC-EXPORT-Statement/m-p/431779#M68687</guid>
      <dc:creator>YHJ</dc:creator>
      <dc:date>2018-01-29T13:44:58Z</dc:date>
    </item>
  </channel>
</rss>

