<?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: Ignoring/Excluding Observation Column in .txt Files When Using Proc Import in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-Excluding-Observation-Column-in-txt-Files-When-Using/m-p/788234#M251963</link>
    <description>&lt;P&gt;Not that easy with proc import, post-processing is required to get a useful dataset. You have to ignore the first row containing the names of the variables, drop the first variable and use proc datasets to rename the variables. A better approach starts by dropping proc import and writing a data step. Have look at the log, the generated code is there, so you could copy it and adapt it to your needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Untested:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myData=/home/u59821735/My Files/MyData;
proc import datafile="&amp;amp;myData/BodyFat.txt" 
			dbms=dlm
			out=body_fat(drop= var1)
			replace;
	guessingrows=max;
        datarow=2;
        getnames=no;
run;

proc datasets library= work nolist;
  modify body_fat;
    rename var2 = Age var3 = Weight /* add other vars here */;
  run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Jan 2022 07:22:50 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-01-04T07:22:50Z</dc:date>
    <item>
      <title>Ignoring/Excluding Observation Column in .txt Files When Using Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-Excluding-Observation-Column-in-txt-Files-When-Using/m-p/788222#M251957</link>
      <description>&lt;P&gt;I am relatively new to SAS and as I was trying to read in a data set from school I came across an interesting problem: the txt file I was trying to import to SAS had an extra observation column and thus "shifted" my columns names to the left one spot of their original position. Is there an option or statement in proc import that allows me to ignore that column so the column names are aligned with their respective data columns?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let myData=/home/u59821735/My Files/MyData;
proc import datafile="&amp;amp;myData/BodyFat.txt" 
			dbms=dlm
			out=body_fat
			replace;
	guessingrows=max;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jdlax00_0-1641269267471.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67096i774355334E48ED52/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jdlax00_0-1641269267471.png" alt="jdlax00_0-1641269267471.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jdlax00_1-1641269299005.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67097i53B3C25D347F2DDE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jdlax00_1-1641269299005.png" alt="jdlax00_1-1641269299005.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 04:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignoring-Excluding-Observation-Column-in-txt-Files-When-Using/m-p/788222#M251957</guid>
      <dc:creator>jdlax00</dc:creator>
      <dc:date>2022-01-04T04:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Ignoring/Excluding Observation Column in .txt Files When Using Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-Excluding-Observation-Column-in-txt-Files-When-Using/m-p/788234#M251963</link>
      <description>&lt;P&gt;Not that easy with proc import, post-processing is required to get a useful dataset. You have to ignore the first row containing the names of the variables, drop the first variable and use proc datasets to rename the variables. A better approach starts by dropping proc import and writing a data step. Have look at the log, the generated code is there, so you could copy it and adapt it to your needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Untested:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myData=/home/u59821735/My Files/MyData;
proc import datafile="&amp;amp;myData/BodyFat.txt" 
			dbms=dlm
			out=body_fat(drop= var1)
			replace;
	guessingrows=max;
        datarow=2;
        getnames=no;
run;

proc datasets library= work nolist;
  modify body_fat;
    rename var2 = Age var3 = Weight /* add other vars here */;
  run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jan 2022 07:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignoring-Excluding-Observation-Column-in-txt-Files-When-Using/m-p/788234#M251963</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-01-04T07:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Ignoring/Excluding Observation Column in .txt Files When Using Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-Excluding-Observation-Column-in-txt-Files-When-Using/m-p/788921#M252366</link>
      <description>Thank you so much! It worked like a charm.</description>
      <pubDate>Fri, 07 Jan 2022 16:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignoring-Excluding-Observation-Column-in-txt-Files-When-Using/m-p/788921#M252366</guid>
      <dc:creator>jdlax00</dc:creator>
      <dc:date>2022-01-07T16:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Ignoring/Excluding Observation Column in .txt Files When Using Proc Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-Excluding-Observation-Column-in-txt-Files-When-Using/m-p/788939#M252379</link>
      <description>&lt;P&gt;Why use PROC IMPORT to read a text file?&lt;/P&gt;
&lt;P&gt;Just write the data step yourself. You will have much more control (and in this case less code).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myData=/home/u59821735/My Files/MyData;
data body_fat ;
  infile "&amp;amp;myData/BodyFat.txt" dsd dlm=' ' firstobs=2 truncover;
  input row brozek age weight height neck chest adbom;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jan 2022 18:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignoring-Excluding-Observation-Column-in-txt-Files-When-Using/m-p/788939#M252379</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-07T18:29:29Z</dc:date>
    </item>
  </channel>
</rss>

