<?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: Import CSV file in certain order of variables in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517572#M16069</link>
    <description>&lt;P&gt;just follow the pattern for the compiler to get the order right&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
informat var1 $10. var2 8. var3 $10.;
input Var3	Var2	Var1 &amp;amp;;
cards;
Cat	44	Grade 1
Dog	22	Grade 3
Bird	5542	Grade 9
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 30 Nov 2018 16:54:23 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-11-30T16:54:23Z</dc:date>
    <item>
      <title>Import CSV file in certain order of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517560#M16064</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to import a csv file in SAS using data step, but I want SAS read the variables as I order them&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;Have:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Var3&lt;/TD&gt;&lt;TD&gt;Var2&lt;/TD&gt;&lt;TD&gt;Var1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Cat&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;Grade 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Dog&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;Grade 3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bird&lt;/TD&gt;&lt;TD&gt;5542&lt;/TD&gt;&lt;TD&gt;Grade 9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Var1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;Var2&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Var3&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Grade 1&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;Cat&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Grade 3&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;Dog&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Grade 9&lt;/TD&gt;&lt;TD&gt;5542&lt;/TD&gt;&lt;TD&gt;Bird&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I tried to rearrange the order of variables , SAS is importing/reading it incorrectly - here is the output from SAS - Its putting the rows under different headers like this - Notice Var1 and Var3 :&lt;/P&gt;&lt;P&gt;&lt;U&gt;Issue:&lt;/U&gt;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Var1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;Var2&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Var3&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Cat&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;Grade 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Dog&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;Grade 3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bird&lt;/TD&gt;&lt;TD&gt;5542&lt;/TD&gt;&lt;TD&gt;Grade 9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I fix this without sorting the vars in the csv&amp;nbsp;file&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 16:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517560#M16064</guid>
      <dc:creator>AZIQ1</dc:creator>
      <dc:date>2018-11-30T16:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file in certain order of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517565#M16065</link>
      <description>&lt;P&gt;Please post your code.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 16:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517565#M16065</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-30T16:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file in certain order of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517568#M16066</link>
      <description>&lt;P&gt;Just DEFINE the variables in a different order than you INPUT them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  infile 'myfile.csv' dsd truncover firstobs=2;
  length var1 $20 var2 8 Var3 $8 ;
  input var3 var2 var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Nov 2018 16:48:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517568#M16066</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-11-30T16:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file in certain order of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517569#M16067</link>
      <description>&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt; &amp;amp;FILENEW_I;&lt;/P&gt;&lt;P&gt;INFILE "filepath\Test.CSV" DSD FIRSTOBS=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Length Var1&amp;nbsp;&amp;nbsp; $&lt;STRONG&gt;6&lt;/STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;Length Var2&amp;nbsp;&amp;nbsp; $&lt;STRONG&gt;8&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;Length Var3&amp;nbsp;&amp;nbsp; $&lt;STRONG&gt;6&lt;/STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;INPUT&lt;/P&gt;&lt;P&gt;Var1&amp;nbsp;&amp;nbsp; $&lt;/P&gt;&lt;P&gt;Var2 $&lt;/P&gt;&lt;P&gt;Var3 $;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 16:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517569#M16067</guid>
      <dc:creator>AZIQ1</dc:creator>
      <dc:date>2018-11-30T16:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file in certain order of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517571#M16068</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Thats what I did, but its reading Var3 data in Var1 and Var1 data in Var3:&lt;/P&gt;&lt;P&gt;Here is my code&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt; &amp;amp;FILENEW_I;&lt;/P&gt;&lt;P&gt;INFILE "filepath\Test.CSV" DSD FIRSTOBS=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Length Var1&amp;nbsp;&amp;nbsp; $&lt;STRONG&gt;6&lt;/STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; ;&amp;nbsp; &amp;nbsp; Length Var2&amp;nbsp;&amp;nbsp; $&lt;STRONG&gt;8&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&amp;nbsp;&amp;nbsp;Length Var3&amp;nbsp;&amp;nbsp; $&lt;STRONG&gt;6&lt;/STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;INPUT&amp;nbsp; Var1&amp;nbsp;&amp;nbsp; $&amp;nbsp; &amp;nbsp;Var2 $&amp;nbsp;&amp;nbsp;Var3 $;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 16:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517571#M16068</guid>
      <dc:creator>AZIQ1</dc:creator>
      <dc:date>2018-11-30T16:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Import CSV file in certain order of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517572#M16069</link>
      <description>&lt;P&gt;just follow the pattern for the compiler to get the order right&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
informat var1 $10. var2 8. var3 $10.;
input Var3	Var2	Var1 &amp;amp;;
cards;
Cat	44	Grade 1
Dog	22	Grade 3
Bird	5542	Grade 9
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Nov 2018 16:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-CSV-file-in-certain-order-of-variables/m-p/517572#M16069</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-30T16:54:23Z</dc:date>
    </item>
  </channel>
</rss>

